实验2
------------恢复内容开始------------
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<time.h> #define N 5 int main() { int grade, number; int i; srand(time(0)); for (i = 0; i < N; ++i) { grade = rand() % 4 + 2018; number = rand() % 999 + 1; printf("%d8330%04d\n", grade, number); } return 0; }

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<time.h> int main() { int date, i, n = 3, num; date = rand() % 30; srand(time(0)); printf("猜一猜2022年4月哪一天是你的lucky day\n开始了,你有三次机会,猜吧(1~30):"); for (i = 0; i < n; i++) { scanf("%d", &num); if (num == date) printf("哇!猜中了!"); else if (num < date) printf("你猜的日期早了,你的lucky day还没到呢\n再猜(1~30):"); else printf("你猜的日期晚了,你的lucky day已经过了\n再猜(1~30):"); } if (i == n) printf("你的次数用完了,偷偷告诉你,4月,你的lucky day是%d号", date); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int main() { char a; while (scanf("%c",&a) != 0) { getchar(); if (a == 'r') printf("stop!\n"); else if (a == 'g') printf("go,go,go\n"); else if (a == 'y') printf("wait a minute\n"); else printf("something must be wrong...\n"); } return 0; }

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<math.h> int main() { int n, a, i, A ; double p, s; while (scanf("%d%d", &n, &a) != 0) { s = 0; A = 0; printf("n=%d,a=%d", n, a); for (i = 0; i <n; i++) { A = A + a * pow(10, i); p = (double)(i+1) / A; s += p; } printf("s=%lf\n", s); } return 0; }

#include<stdio.h> int main() { int i, j; for (i = 1; i < 10; i++) { for (j = 1; j <= i; j++) printf("%dX%d = %2d ", j, i, i * j); printf("\n"); } return 0; }

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int main() { int i, j; printf("Input n: " ); scanf("%d", &i); for (j = 0; j < i; j++) { printf(" O \n"); printf("<H>\n"); printf("I I\n\n"); } return 0; }

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int main() { int i, n; printf("Input n: "); scanf("%d", &n); for (i = 0; i < n; i++) printf(" O "); printf("\n"); for(i=0;i<n;i++) printf("<H> "); printf("\n"); for(i=0;i<n;i++) printf("I I "); return 0; }

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int main() { int i, n; printf("Input n: "); scanf("%d", &n); for (i = 0; i < n; i++) printf(" O "); printf("\n"); for(i=0;i<n;i++) printf("<H> "); printf("\n"); for(i=0;i<n;i++) printf("I I "); return 0; }


------------恢复内容结束------------

浙公网安备 33010602011771号