电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

C语言源代码

C语言源代码_第1页
1/19
C语言源代码_第2页
2/19
C语言源代码_第3页
3/19
剪刀石头布源代码 #include #include main() { int d,x; { printf("请输入:1 是剪刀,2 是石头,3 是布"); scanf("%d",&d); x=rand()%3; if(d==x) printf("双方平局"); else if((d==1&&x==2)||(d==2&&x==3)||(d==3&&x==1)) printf("你赢了"); else printf("电脑赢了"); } } 简单计算器 #include main() { int a,b,d=0; char c; while(d==0) { printf("请开始计算,请输入需要运算的数字和运算法则,数字 符号 数字:"); scanf("%d%c%d",&a,&c,&b); switch(c) { case'+': printf("%d+%d=%d\n",a,b,a+b); break; case'-': printf("%d-%d=%d\n",a,b,a-b); break; case'*': printf("%d*%d=%d\n",a,b,a*b); break; case'/': if(0==b) printf("除法被除数不能为零!\n") ; else printf("%d/%d=%d\n",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("请输入您要的加油量:"); scanf("%d",&x); printf("请输入您要的汽油种类,1-a 型汽油售价3.25 元/千克, 2-b 型汽油售价3.00 元/千克, 3-c 型汽油售价2.75 元/千克:"); scanf("%d",&y); printf("请输入您要的服务类型,1-自己加 服务优惠0.05,2-协助加 服务优惠0.10:"); scanf("%d",&z); 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 * x; printf("您需要支付:%f 元,谢谢惠顾,欢迎下次再来",m); return 0; } 猜数字游戏 #include #include int main() { int d=1,e=0; int a,b,t; printf ("请输入1-10 以内的整数,\n "); while(d==1) { printf("玩家的选择: "); scanf("%d",&a); do { if((a>=0)&&(a<11))break; else {printf("错误"); scanf("%d",&a);} } while(e==0); b=rand()%10+1; printf("npc:%d",b); t=a-b; if(t==0) printf("\nRight!\n"); else if(t<0) printf("\n Wrong !太小了\ n"); else if(t>0) printf("\n Wrong !太大了\ n"); } return 0; } 万年历 #include #include void setmon...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

C语言源代码

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部