实验1
代码
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 #include <windows.h> 5 #define N 80 6 7 void print_text(int line, int col, char text[]); 8 void print_spaces(int n); 9 void print_blank_lines(int n); 10 11 int main(){ 12 int line, col, i ; 13 char text[N]="hi,November~"; 14 15 srand(time(0)); 16 17 for(i = 1; i <= 10; ++i){ 18 line = rand() % 25; 19 col =rand() % 80; 20 print_text(line,col,text); 21 Sleep(1000); 22 } 23 return 0; 24 } 25 void print_spaces(int n){ 26 int i; 27 28 for(i=1;i<=n;++i) 29 printf(" "); 30 31 } 32 33 void print_blank_lines(int n){ 34 int i; 35 36 for(i=1;i<=n;++i) 37 printf("\n"); 38 } 39 40 void print_text(int line,int col,char text[]){ 41 print_blank_lines(line-1); 42 print_spaces(col-1); 43 printf("%s",text); 44 }
截图
实验2
2.1.1代码
1 #include <stdio.h> 2 long long fac(int n); 3 4 int main(){ 5 int i, n; 6 7 printf("Enter n: "); 8 scanf("%d",&n); 9 for (i = 1; i <= n; ++i) 10 printf("%d! = %lld\n", i, fac(i)); 11 12 return 0; 13 14 } 15 long long fac(int n){ 16 static long long p = 1; 17 18 p = p * n; 19 20 21 return p; 22 }
截图
代码2.1.2
1 #include <stdio.h> 2 long long fac(int n); 3 4 int main(){ 5 int i, n; 6 7 printf("Enter n: "); 8 scanf("%d",&n); 9 for (i = 1; i <= n; ++i) 10 printf("%d! = %lld\n", i, fac(i)); 11 12 return 0; 13 14 } 15 long long fac(int n){ 16 static long long p = 1; 17 18 p = p * n; 19 printf("p = %lld\n", p); 20 21 return p; 22 }
截图
代码2.2
1 #include <stdio.h> 2 int func(int, int); 3 4 5 int main(){ 6 int k = 4,m = 1, p1, p2; 7 8 p1 = func(k,m); 9 p2 = func(k,m); 10 printf("%d, %d\n", p1, p2); 11 12 return 0; 13 } 14 15 int func(int a, int b) { 16 static int m = 0, i = 2; 17 18 i +=m + 1; 19 m = i + a + b; 20 21 return m; 22 }
截图
实验3
代码
标签:截图,include,int,long,实验,func,main From: https://www.cnblogs.com/z00z/p/17798400.html