1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 #define N 5 5 int main() 6 { 7 int number; 8 int i; 9 srand(time(0)); 10 for (i = 0; i < N; ++i) { 11 number = rand() % 500 + 1; 12 printf("20228329%04d\n", number); 13 } 14 return 0; 15 } 16 17 18 19 20 //问题1:从1~500中随机产生1个数 21 22 //问题2:随机点5个学号在202283290001-202283290500的学生
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 int main() 5 { 6 srand(time(0)); 7 int day, a; 8 day= rand() % 30+ 1; 9 printf("猜猜2022年11月哪一天会是你的lucky day\n开始喽,你有三次机会,猜吧(1~30):\n"); 10 for (int i = 0; i < 3; i++) 11 { 12 scanf_s("%d", &a); 13 if (a == day) 14 { 15 printf("哇,猜中了\n"); 16 break; 17 } 18 else if (a > day) 19 { 20 printf("你的日期晚了,你的lucky day 已经过了\n"); 21 continue; 22 } 23 else (a < day); 24 { 25 printf("你的日期早了,你的lucky day 还没到呢\n"); 26 continue; 27 } 28 29 } 30 if (a != day) 31 { 32 printf("次数用完啦下,偷偷告诉你:11月你的licky day 是%d号", day); 33 } 34 35 36 }
1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 char a; 6 7 for (;;) 8 { 9 scanf_s("%c", &a); 10 getchar(); 11 12 switch (a) 13 { 14 case 'r': 15 printf("stop!\n"); 16 break; 17 case 'y': 18 printf("wait a minute\n"); 19 break; 20 case 'g': 21 printf("go go go\n"); 22 break; 23 default: 24 printf("something must be wrong...\n"); 25 } 26 } 27 }
1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 for (;;) 6 { 7 double s = 0.0; 8 int a, n,t; 9 10 11 scanf_s("%d%d", &n, &a); 12 printf("n=%d a=%d\n", n, a); 13 t = a; 14 for (int i = 1; i <= n; i++) 15 { 16 17 s =s+ i *1.0/ t; 18 t = 10 * t + a; 19 } 20 printf("s=%lf", s); 21 22 } 23 24 25 }
1 #include<stdio.h> 2 int main() 3 { 4 int s; 5 6 7 for (int i = 1; i <= 9; i++) 8 { 9 for (int j = 1; j <= i; j++) 10 { 11 s = i * j; 12 13 printf("%d*%d=%d\t",i,j ,s); 14 15 } 16 printf("\n"); 17 } 18 19 20 21 22 }
1 //第i行有2n-2i+1个小人 2 //第i行有i—1个\t 3 4 #include<stdio.h> 5 void space(int n) 6 { 7 for (int j = 1; j <= n; j++) 8 { 9 printf("\t"); 10 } 11 } 12 void people(int q) 13 { 14 for (int m = 1; m <= q; m++) 15 { 16 17 printf(" O \n"); 18 printf("<H>\n"); 19 printf("I I\n"); 20 } 21 } 22 void head(int q) 23 { 24 for (int m = 1; m <= q; m++) 25 { 26 27 printf(" O \t"); 28 29 } 30 } 31 void body(int q) 32 { 33 for (int m = 1; m <= q; m++) 34 { 35 36 37 printf("<H>\t"); 38 39 } 40 } 41 void leg(int q) 42 { 43 for (int m = 1; m <= q; m++) 44 { 45 46 47 printf("I I\t"); 48 } 49 } 50 int main() 51 { 52 int s; 53 printf("请输入共多少行:"); 54 int t; 55 int n; 56 scanf_s("%d", &n); 57 for (int i = 1; i <= n; i++) 58 { 59 s = i - 1; 60 t = 2 * n - 2 * i + 1; 61 space(s); 62 head(t); 63 64 printf("\n"); 65 space(s); 66 body(t); 67 printf("\n"); 68 space(s); 69 leg(t); 70 71 72 73 printf("\n"); 74 } 75 76 }
标签:语句,11,main,int,编程,C语言,printf,include,day From: https://www.cnblogs.com/libeiqundad/p/16806839.html