剪刀石头布源代码#include<stdio.h>#include<stdlib.h>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("你赢了");elseprintf("电脑赢了");}}简单计算器#include<stdio.h>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") ;elseprintf("%d/%d=%d\n",a,b,a/b);break;}}}加油站加油问题#include<stdio.h>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<stdio.h>#include<stdlib.h>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<stdio.h>#include<stdlib.h>void setmonth(int r);void main(void){int year,month,day,a,b,i,j,d,x,mon,k;do{printf("----------------------------------------------------\n");printf(" 查全年,输入1!\n");printf(" 查月份,输入2!\n");printf(" 查日期,输入3!\n");printf(" 继续?输入4!\n");printf(" 退出,输入5!\n");printf("-----------------------------------------------------\n");printf("请输入:");scanf("%d",&x);if(x==1){month=12;printf("输入年份:");scanf("%d",&year);}if(x==2){printf("输入年份:");scanf("%d",&year);printf("输入月份:");scanf("%d",&month);}if(x==3){printf("输入年份:");scanf("%d",&year);printf("输入月份:");scanf("%d",&mon);printf("输入日期:");scanf("%d",&day);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<=month;i++){switch(i){case 1:case 3:case 5:case 7:case 8:case 10:case 12:d=31;break;case 2:if(!(year%4)&&(year%100)||!(year%400))d=29;elsed=28;break;case 4:case 6:case 9:case 11:d=30;}b=a%7;a+=d;if(x==1){printf("========================================================\n");setmonth(i);printf("************************************************\n");printf("========================================================\n");printf(" 星期一星期二星期三星期四星期五星期六星期天\n");for(j=1;j<=b;j++)printf("%8c",' ');for(j=1;j<=d;j++){printf("%8d",j);if((j+b)%7==0)printf("\n");}}if(x==1)printf("\n");}if(x==2){printf("========================================================\n");setmonth(i-1);printf("************************************************\n");printf("========================================================\n");printf(" 星期一星期二星期三星期四星期五星期六星期天\n");for(j=1;j<=b;j++)printf("%8c",' ');for(j=1;j<=d;j++){printf("%8d",j);if((j+b)%7==0)printf("\n");}printf("\n");}if(x==3){a+=day;a%=7;switch(a){case 0:printf("%d.%d.%d 星期一!",year,mon,day);break;case 1:printf("%d.%d.%d 星期二!",year,mon,day);break;case 2:printf("%d.%d.%d 星期三!",year,mon,day);break;case 3:printf("%d.%d.%d 星期四!",year,mon,day);break;case 4:printf("%d.%d.%d 星期五!",year,mon,day);break;case 5:printf("%d.%d.%d 星期六!",year,mon,day);break;default:printf("%d.%d.%d 星期天!",year,mon,day);}printf("\n");}printf("是否继续?输入4继续,输入5退出:");scanf("%d",&k);} while(k==4);if(k==5)exit(100);}void setmonth(int r){switch(r){case 1:printf("%4c 一月份",' ');break;case 2:printf("%4c 二月份",' ');break;case 3:printf("%4c 三月份",' ');break;case 4:printf("%4c 四月份",' ');break;case 5:printf("%4c 五月份",' ');break;case 6:printf("%4c 六月份",' ');break;case 7:printf("%4c 七月份",' ');break;case 8:printf("%4c 八月份",' ');break;case 9:printf("%4c 九月份",' ');break;case 10:printf("%4c 十月份",' ');break;case 11:printf("%2c 十一月份",' ');break;default:printf("%2c 十二月份",' ');}}ATM机# include<stdio.h># include<stdlib.h># define Password 123456main (){int a,i,b,q,c;float m;m=3000.00;for (i=0;i<=2;i++){printf("请输入密码\n");scanf("%d",&a);if(a==Password){printf("密码正确,欢迎使用\n");break;}elseprintf("密码错误,请重新输入\n");}{if (a!=Password)printf("您的操作错误超过3次,请取回卡\n");else{system("cls");printf("1.取款\n2.存款\n3.查询余额\n4.退出\n");}}while(b!=4){scanf("%d",&b);switch(b){case 1: system("cls");printf("请输入你要取款的金额\n");scanf(" %d",&q); printf("取款成功,请选择你要进行的操作\n");m=m-q;break;case 2: system("cls");printf("请输入你要存入的金额\n");scanf(" %d",&c);m=m+c;;printf("存款成功,请选择你要进行的操作\n");break;case 3: system("cls");printf("您的余额为%.2f\n",m);break;case 4: system("cls");printf("谢谢使用");break;}}return 0;}学生成绩#include <stdio.h>#include <stdlib.h>float s[3][4];int r=0,c=0;void pjf(void){int i,j,cour = 0;for(j=0;j<4;j++){for(i=0;i<3;i++)cour+=s[i][j];printf("第%d课的平均分是%d\n",(j+1),cour/3);cour = 0;}}void dkzg(void){int i,j,high=0;for(j=0;j<4;j++){for(i=0;i<3;i++){if(s[i][j]>high){high=s[i][j];r=i+1;c=j+1;}}printf("最高分是%d,学生是%d,课程是%d\n",high,r,c);r=0;c = 0;high = 0;}}int main(){int i,j;float score=0;for(i=0;i<3;i++){printf("enter NO.%d score\n",i+1);for(j=0;j<4;j++){scanf("%f",&s[i][j]);score += s[i][j];}printf("第%d个学生的平均分是%f\n",(i+1),score/4);score = 0;}pjf();dkzg();return 0;}选票问题#include <stdio.h>void main(){int i=1;char j;int num[4]={0,0,0,0};printf("3位候选人,分别为A,B,C D为无效票,开始投票\n"); while(i<=10){printf("请输入第%d个的选票",i);scanf("%c",&j);switch(j){case 'A':num[0]++;i++;break;case 'B':num[1]++;i++;break;case 'C':num[2]++;i++;break;case 'D':num[3]++;i++;break;}getchar();}printf("A获得%d张选票\n",num[0]);printf("B获得%d张选票\n",num[1]);printf("C获得%d张选票\n",num[2]);printf("无效票为%d张\n",num[3]);}打字母游戏#include <graphics.h>#include <conio.h>#include <time.h>#include <stdlib.h>#include <dos.h>#include <stdio.h>// 欢迎界面void welcome(){// 输出屏幕提示cleardevice(); //清除屏幕内容,用当前背景色清空屏幕,并将当前点移至(0, 0)。