1 //---------------------1 2 #include<stdio.h> 3 void main() 4 { 5 int a,b,c; 6 printf("输入三个正整数,a,b,c"); 7 scanf("%d%d%d",&a,&b,&c); 8 if(a>b&&a>c)//很好的算法,求出三个数的最大值 9 if(b>c) 10 printf("%d%d%d\n",a,b,c); 11 else 12 printf("%d%d%d",a,c,b); 13 else if(b>a&&b>c) 14 if(a>c) 15 printf("%d%d%d\n",b,a,c); 16 else 17 printf("%d%d%d\n",b,c,a); 18 else 19 if(a>b) 20 printf("%d%d%d\n",c,a,b); 21 else 22 printf("%d%d%d\n",c,b,a); 23 } 24 //---------------2 25 #include<stdio.h> 26 void main() 27 { 28 int a,b,c,t; 29 printf("输入三个正整数a,b,c"); 30 scanf("%d%d%d",&a,&b,&c); 31 if(a<b) 32 {t=a;a=b;b=t;} 33 if(a<c) 34 {t=b;a=c;c=t;} 35 if(b<c) 36 {t=b;b=c;c=t;} 37 printf("%d%d%d\n",a,b,c); 38 } 39 //----------------------------3 40 #include<stdio.h> 41 void main() 42 { 43 int g; 44 printf("输入成绩:g"); 45 scanf("%d",&g); 46 if(g>=85&&g<=100) 47 printf("优秀"); 48 else 49 if(g>=75&&g<=84) 50 printf("良好"); 51 else 52 if(g>=64&&g<=74) 53 printf("及格"); 54 else 55 printf("不及格"); 56 } 57 //----------------------4 58 #include<stdio.h> 59 void main() 60 { 61 int d; 62 printf("输入一个正整数:\n"); 63 scanf("%d",&d); 64 switch (d) 65 { 66 case 1:printf("monday\n");break; 67 case 2:printf("tuesday\n");break; 68 case 3:printf("wednesday\n");break; 69 case 4:printf("thursday\n");break; 70 case 5:printf("friday\n");break; 71 case 6:printf("saturday\n");break; 72 case 7:printf("sunday\n");break; 73 default:printf("you input error?\n");break; 74 } 75 } 76 //---------------------------------5 77 #include<stdio.h> 78 void main() 79 { 80 int year,month; 81 printf("输入年和月:"); 82 scanf("%d%d",&year,&month); 83 switch (month) 84 { 85 case 1: 86 case 3: 87 case 5: 88 case 7: 89 case 8: 90 case 10: 91 case 12: 92 printf("%d%d has 31 days\n.",year,month);break; 93 case 4: 94 case 6: 95 case 9: 96 case 11: 97 printf("%d%d has 30 days\n",year,month);break; 98 case 2: 99 if(year%4==0&&year%100!=0||year%400==0) 100 {printf("%d%d has 29 days\n.",year,month);break;} 101 else 102 { 103 104 printf("%d%d has 28 days\n.",year,month);break; 105 } 106 default: 107 printf("you input error!\n"); 108 } 109 } 110 //-----------------------------6 111 #include<stdio.h> 112 void main() 113 { 114 int c; 115 printf("Enter 1 or 0"); 116 scanf("%d",&c); 117 while(c==1) 118 { 119 printf("*******\n"); 120 printf("Enter 1 or 0"); 121 scanf("%d",&c);//突然想起和那个递归的形式差不多 122 } 123 } 124 //-----------------------------7 125 #include<stdio.h> 126 void main() 127 { 128 int c; 129 do 130 { 131 printf("*******\n"); 132 printf("Enter 1 or 0"); 133 scanf("%d",&c); 134 }while (c==1); 135 } 136 //-----------------------------8 137 #include<stdio.h> 138 void main() 139 { 140 int i,n; 141 printf("Enter role n:"); 142 scanf("%d",&n); 143 for(i=0;i<=n;i++)//n+1行 144 { 145 printf("*******"); 146 printf("\n"); 147 } 148 } 149 //-----------------------------9 150 #include<stdio.h> 151 void main() 152 { 153 int i,s=0; 154 for(i=1;i<=10;i++) 155 { 156 s=s+i; 157 } 158 printf("s=%d\n",s); 159 } 160 //---------------------------------10 161 #include<stdio.h> 162 void main() 163 { 164 int i,n,t=1; 165 printf("Enter n:"); 166 scanf("%d",&n); 167 for(i=1;i<=n;i++) 168 { 169 t=t*i; 170 } 171 printf("t=%d\n",t); 172 } 173 //------------------------------------11 174 #include<stdio.h> 175 void main() 176 { 177 int i,k,n; 178 printf("Enter n?"); 179 scanf("%d",&n); 180 k=n-1; 181 for(i=2;i<=k;i++) 182 { 183 if(n%i==0) 184 break; 185 } 186 if(i>k) 187 printf("%d is 素数\n",n); 188 else 189 { 190 printf("%d not is 素数\n",n); 191 }