1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 struct student{
 5     int num;
 6     char str[20];
 7     double dec;
 8 };
 9 
10 void scan(struct student *stu[], int *n){    
11     scanf("%d", n);
12     *stu = (struct student *)malloc(*n * sizeof(struct student));
13 
14     for(int i = 0; i < *n; ++i){
15         scanf("%d%s%lf", &(*stu)[i].num, (*stu)[i].str, &(*stu)[i].dec);
16     }
17 }
18 
19 void print(struct student stu[], int n){    
20 
21     printf("%d\n", n);
22     for(int i = 0; i < n; ++i){
23         printf("%d %s %lf\n", stu[i].num, stu[i].str, stu[i].dec);
24     }
25 }
26 
27 int main(){
28     int n;
29     struct student *stu;
30     
31     scan(&stu, &n);
32     print(stu, n);
33 
34     free(stu);
35     return 0;
36 }
37 /*
38 3
39 20 字符串0 20.02
40 21 字符串1 21.12
41 22 字符串2 22.22
42 */

 

相关文章:

  • 2021-12-28
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-06-30
  • 2021-04-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案