C语言-源代码详细资料.doc
《C语言-源代码详细资料.doc》由会员分享,可在线阅读,更多相关《C语言-源代码详细资料.doc(19页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、剪刀石头布源代码剪刀石头布源代码#include #includemain() int d,x;printf(“请输入:1 是剪刀,2 是石头,3 是布“);scanf(“%d“,x=rand()%3;if(d=x)printf(“双方平局“);else if(d=1elseprintf(“电脑赢了“);简单计算器简单计算器#include main() int a,b,d=0; char c; while(d=0) printf(“请开始计算,请输入需要运算的数字和运算法则,数字 符号 数字:“);scanf(“%d%c%d“,switch(c)case+:printf(“%d+%d=%dn
2、“,a,b,a+b);break;case-:printf(“%d-%d=%dn“,a,b,a-b);break;case*:printf(“%d*%d=%dn“,a,b,a*b);break;case/:if(0=b)printf(“除法被除数不能为零!n“) ;elseprintf(“%d/%d=%dn“,a,b,a/b);break; 加油站加油问题加油站加油问题#include int main() double a = 3.25, b = 3.00, c= 2.75;double d = 0.05, e = 0.10, m;int x,y,z;printf(“请输入您要的加油量:“)
3、; scanf(“%d“,printf(“请输入您要的汽油种类,1-a 型汽油售价 3.25 元/千克, 2-b 型汽油售价 3.00 元/千克,3-c 型汽油售价 2.75 元/千克:“);scanf(“%d“,printf(“请输入您要的服务类型,1-自己加 服务优惠 0.05,2-协助加 服务优惠 0.10:“);scanf(“%d“,switch(y)case 1:y = a;break;case 2:y = b;break;case 3:y = c;break; if(z = 1)m = (1 - d) * y * x;else if(z = 2)m = (1 - e) * y *
4、x;printf(“您需要支付:%f 元,谢谢惠顾,欢迎下次再来“,m);return 0; 猜数字游戏猜数字游戏#include #includeint main() int d=1,e=0; int a,b,t; printf (“请输入 1-10 以内的整数,n “); while(d=1) printf(“玩家的选择: “); scanf(“%d“,do if(a=0) return 0; 万年历万年历#include #include void setmonth(int r); void main(void) int year,month,day,a,b,i,j,d,x,mon,k;
5、do printf(“-n“); printf(“ 查全年,输入 1!n“); printf(“ 查月份,输入 2!n“); printf(“ 查日期,输入 3!n“); printf(“ 继续?输入 4!n“); printf(“ 退出,输入 5!n“); printf(“-n“); printf(“请输入:“); scanf(“%d“, if(x=1) month=12; printf(“输入年份:“); scanf(“%d“, if(x=2) printf(“输入年份:“); scanf(“%d“, printf(“输入月份:“); scanf(“%d“, if(x=3) printf(
6、“输入年份:“); scanf(“%d“, printf(“输入月份:“); scanf(“%d“, printf(“输入日期:“); scanf(“%d“, month=mon-1; if(x=5) exit(100); a=(year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400)%7; for(i=1,d=0;i # include # define Password 123456 main () int a,i,b,q,c; float m; m=3000.00; for (i=0;i #include float s34; int r=0,c
7、=0;void pjf(void) int i,j,cour = 0;for(j=0;jhigh)high=sij;r=i+1;c=j+1; printf(“最高分是%d,学生是%d,课程是%dn“,high,r,c); r=0; c = 0; high = 0; int main() int i,j;float score=0;for(i=0;i void main() int i=1; char j; int num4=0,0,0,0; printf(“3 位候选人,分别为 A,B,C D 为无效票,开始投票n“); while(i #include #include #include #
8、include #include / 欢迎界面 void welcome() / 输出屏幕提示 cleardevice(); /清除屏幕内容,用当前背景色清空屏幕,并将当前点移至 (0, 0)。 setcolor(RED); /设置当前绘图前景色为红色,字体颜色为红色 setfont(64, 0, “黑体“);/设置当前字体样式为黑体,大小为 64 outtextxy(160, 50, “打字母游戏“);/在指定位置输出字符串。 setcolor(GREEN);/设置当前绘图前景色为绿色,即文字颜色为绿色 setfont(16, 0, “宋体“);/设置当前字体样式为宋体 outtextxy(
9、200, 200, “本游戏是一个简单传统的游戏“);/在指定位置输出字符串。 outtextxy(200, 240, “就是随机出现些字母然后游戏“);/在指定位置输出字符串。 outtextxy(200, 280, “者敲键盘把它消除用以锻炼游“);/在指定位置输出字符串。 outtextxy(200, 320, “者的反应能力,来试试吧“);/在指定位置输出字符串。 / 实现闪烁的“按任意键继续“ int c=255; while(!kbhit() /没有按键时循环继续 setcolor(RGB(c, 0, 0);/设置当前绘图前景色为红色色 outtextxy(280, 400, “按
10、任意键继续“);/在指定位置输出字符串 c -= 8; /变量 c 的值自减去 8 if (c 0) c = 255; Sleep(20);/调用 Sleep()函数延时 20 毫秒 getch();/等待用户从键盘按任意一个键,退出循环 cleardevice();/用当前背景色清空屏幕,并将当前点移至 (0, 0)。 / 难度界面 int welcome2() int i;/ 输出屏幕提示 cleardevice(); /清除屏幕内容,用当前背景色清空屏幕,并将当前点移至 (0, 0)。 setcolor(YELLOW); /设置当前绘图前景色为黄色,字体颜色为黄色 setfont(64,
11、 0, “黑体“);/设置当前字体样式为黑体,大小为 64 outtextxy(160, 50, “难度选择“);/在指定位置输出字符串。setcolor(GREEN);/设置当前绘图前景色为绿色,即文字颜色为绿色 setfont(16, 0, “宋体“);/设置当前字体样式为宋体 outtextxy(100, 160, “初级“);/在指定位置输出字符串。 outtextxy(100, 200, “中级“);/在指定位置输出字符串。 outtextxy(100, 240, “高级“);/在指定位置输出字符串。 outtextxy(100, 280, “终极“);/在指定位置输出字符串。out
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 源代码 详细资料
限制150内