1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<time.h> 4 5 int main() 6 { 7 srand(time(0)); 8 9 int date = rand() % 31 + 1; 10 int x; 11 int i; 12 13 printf_s("猜猜2022年11月哪一天会是你的lucky day\n\n"); 14 printf_s("开始喽,你有三次机会,猜吧(1-30):"); 15 16 for (i = 1; i <= 3; i++) 17 { 18 scanf_s("%d", &x); 19 if (x == date) { 20 printf_s("哇,猜中了:-)"); 21 return 0; 22 } 23 else { 24 if (x < date) { 25 printf_s("你猜的时间早了,你的lucky day还没到呢\n"); 26 printf_s("再猜(1-30):"); 27 } 28 else { 29 printf_s("你猜的时间晚了,你的lucky day已经过啦\n"); 30 printf_s("再猜(1-30):"); 31 } 32 } 33 } 34 printf_s("\b\b\b\b\b\b\b\b\b\b\b\b\b\b-------------------------------------"); 35 printf_s("\n\n"); 36 printf_s("次数用完啦。偷偷告诉你:11月,你的lucky day是 % d号", date); 37 return 0; 38 }
1 #include<stdio.h> 2 3 int main() 4 { 5 char x; 6 int i; 7 int j=2; 8 9 for (i = 1; i < j; i++,j++) { 10 if (i == 1) { 11 scanf_s("%c", &x); 12 } 13 else { 14 getchar(); 15 scanf_s("%c", &x); 16 } 17 switch (x) { 18 case 'r': 19 printf_s("stop!\n"); 20 break; 21 case 'g': 22 printf_s("go go go\n"); 23 break; 24 case 'y': 25 printf_s("wait a minute\n"); 26 break; 27 default: 28 printf_s("something must be wrong...\n"); 29 break; 30 } 31 } 32 }
1 #include<stdio.h> 2 #include<math.h> 3 4 int main() 5 { 6 int n,c; 7 double s=0,x,k,a,w; 8 int i; 9 int j = 2; 10 11 for (i = 1; i < j; i++, j++) { 12 scanf_s("%d%lf", &n, &a); 13 14 c = a; 15 w = a; 16 17 for (k = 1; k <=n; k++,a=a*10+w) { 18 x = (k / (double)a); 19 s = x + s; 20 } 21 22 printf("n=%d,a=%d,s=%lf\n", n, c, s); 23 s = 0; 24 } 25 }
1 #include <stdio.h> 2 #include <math.h> 3 4 int main() 5 { 6 int i = 1;//行数控制 7 int j = 1;//列数控制 8 int h, l;//行数列数暂存 9 int c;//参数存放 10 11 for (; i <= 9; i++) { 12 for (; j <= i; j++) { 13 h = i; 14 l = j; 15 c = i * j; 16 printf_s("%d×%d=%d\t", i, j, c); 17 } 18 19 j = 1; 20 printf_s("\n\n"); 21 } 22 23 }
标签:语句,11,main,int,编程,C语言,break,printf,include From: https://www.cnblogs.com/wsb666/p/16810006.html