test 1
#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; }
test 2
#include<stdio.h> #include<stdlib.h> #include<time.h> int main() { int number; int i; int n; srand(time(0)); number = rand() % 30 + 1; printf("猜猜2022年11月哪一天会是你的lucky day\n"); printf("开始喽,你有三次机会,猜吧(1-30):"); for (i = 0; i < 3; ++i) { scanf_s("%d", &n); if (n == number) { printf("哇,你猜对了"); break; } else if (n < number) { printf("你猜的日期早了,你的lucky day还没到呢\n再猜:"); } else (n > number); { printf("你猜的日期晚了,你的lucky day已经过了\n再猜:"); } } printf("次数用完了。偷偷告诉你:11月,你的路lucky day是%d号",number); return 0; }
test 3
#include <stdio.h> int main() { char n; do { n = getchar(); getchar(); if (n == 'r') { printf("stop!\n"); } else if (n == 'g') { printf("go go go\n"); } else if (n == 'y') { printf("wait a minute\n"); } else { printf("something must be wrong\n"); } } while (n != EOF); return 0; }
test 4
#include<stdio.h> #include<stdlib.h> #include<math.h> int main() { double s=0.0; int a, n; while ( scanf_s("%d%d", &n, &a) != EOF) { int t; printf("n=%d a=%d\t", n, a); t = a; for (int i = 1; i <= n; i++) { s = s + i * 1.0 / t; t = 10 * t + a; } printf("s=%lf\n", s); } system("pause"); return 0; }
test 5
#include<stdio.h> #include<stdlib.h> int main() { int l, c, v; for (l = 1; l < 10; ++l) { for (c = 1; c <= l; ++c) { v = l * c; printf("%d*%d=%d\t",l,c,v); } printf("\n"); } return 0; }
test 6
#include<stdio.h> int main() { int n, i, j, a; printf("input:"); scanf_s("%d", &n); for (j = 1; j <= n; j++) { for (a = 0; a <= j; a++) { printf("\t"); } for (i = 0; i < 2 * (n - j) + 1; i++) { printf(" o \t"); } printf("\n"); for (a = 0; a <= j; a++) { printf("\t"); } for (i = 0; i < 2 * (n - j) + 1; i++) { printf("<H>\t"); } printf("\n"); for (a = 0; a <= j; a++) { printf("\t"); } for (i = 0; i < 2 * (n - j) + 1; i++) { printf("I I\t"); } printf("\n"); } return 0; }
标签:main,int,number,实验,printf,test,include From: https://www.cnblogs.com/chaihao/p/16821473.html