#include <stdio.h> #include <stdlib.h> #include <time.h> #define N 5 int main() { int number; int i; srand(time(0)); // 以当前系统时间作为随机种子 for (i = 0; i < N; ++i) { number = rand() % 500 + 1; printf("20228329%04d\n", number); } return 0; }
#include<stdio.h> int main() { int n,m; printf("猜猜2022年11月哪一天会是你的lucky day\n"); printf("开始喽,你有三次机会,猜吧(1~38):"); srand(time(0)); m = rand() % 31 + 1; for(int i=1;i<=3;i++) {scanf_s("%d",&n); if (n < m) { printf("你猜的日期早了,你的lucky day还没到呢\n"); printf("再猜(1~38):"); continue; } if (n == m) { printf("哇,猜中了:-"); break; } else if(n>m) { printf("你猜的日期晚了,你的lucky day已经过啦\n"); printf("再猜(1~38):"); continue; } } if (n != m) { printf("次数用完啦。偷偷告诉你:11月你的lucky day是%d号\n", m); } }
#include<stdio.h> int main() { char x; while (scanf_s("%c",&x,1) != EOF) { if(x=='r') { printf("stop\n"); getchar(); continue; } if (x == 'g') { printf("go go go \n"); getchar(); continue; } if (x == 'y') { printf("wait a minute\n"); getchar(); continue; } else { printf("something must be wrong ...\n"); getchar(); continue; } } }
#include<stdio.h> #include<math.h> int TF3(); int main() { int n, a; double s=0; while (scanf_s("%d", &n) != EOF) { scanf_s("%d", &a); int y = a; for (int x=n;x>=1;x--) { s = 1.0 * x / TF3(a, x) + s * 1.0; if (y >1) { y--; } } printf("n=%d a=%d s=%lf\n", n, a, s); } } int TF3(int y,int n) { int a = 0; for (;n>=0;n--) { a= y* pow(10, n-1) + a; } return a; }
#include<stdio.h> int TFboy(); int main() { for (int a = 1;a<=9;a++) { for (int b = 1;b<=a;b++) { int s = TFboy(a, b); printf("%d*%d=%2d\t",a,b,s); if (a == b) { printf("\n"); } } } } int TFboy(int a,int b) { int s = a * b; return s; }
#include<stdio.h> int TFboy(int n) { int s = 2 * n - 1; return s; } int main() { int n; printf("input n:"); scanf_s("%d", &n); for (int j=1; n >= 1; n--,j++) {for(int i=1;i<=j;i++) { printf("\t"); } for (int i = 1; i <= TFboy(n); i++) { printf(" O \t"); } printf("\n"); for (int i = 1; i <= j; i++) { printf("\t"); } for (int i = 1; i <= TFboy(n); i++) { printf("<H>\t"); } printf("\n"); for (int i = 1; i <= j; i++) { printf("\t"); } for (int i = 1; i <= TFboy(n); i++) { printf("I I\t"); } printf("\n"); } }
标签:include,int,continue,实验,printf,main,TFboy From: https://www.cnblogs.com/tfbw/p/16809757.html