📄 main.lst
字号:
C51 COMPILER V6.23a MAIN 11/20/2002 18:03:07 PAGE 1
C51 COMPILER V6.23a, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c LARGE DEBUG OBJECTEXTEND
stmt level source
1 #include <REG52.H> /* special function register declarations */
2 /* for the intended 8051 derivative */
3
4 #include <stdio.h> /* prototype declarations for I/O functions */
5 #include<stdlib.h>
6 #ifdef MONITOR51 /* Debugging with Monitor-51 needs */
char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
#endif /* Stop Exection with Serial Intr. */
9 /* is enabled */
10 /*------------------------------------------------
11 The main C function. Program execution starts
12 here after stack initialization.
13 ------------------------------------------------*/
14
15 struct stu
16 {
17 char name[20];
18 long number;
19 float score[4];
20 } ;
21
22 //void delay();
23
24 void main (void) {
25 1 void input(struct stu arr[],int n);/*函数声明*/
26 1 void aver(struct stu arr[],int n);
27 1 void order(struct stu arr[],int n);
28 1 void output(struct stu arr[],int n);
29 1 void out_row(struct stu arr[],int n);
30 1 struct stu stud[4];/*定义结构体数组*/
31 1 /*------------------------------------------------
32 1 Setup the serial port for 1200 baud at 16MHz.
33 1 ------------------------------------------------*/
34 1 #ifndef MONITOR51
35 1 SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
36 1 TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
37 1 TH1 = 221; /* TH1: reload value for 1200 baud @ 16MHz */
38 1 TR1 = 1; /* TR1: timer 1 run */
39 1 TI = 1; /* TI: set TI to send first char of UART */
40 1 #endif
41 1 /*------------------------------------------------
42 1 Note that an embedded program never exits (because
43 1 there is no operating system to return to). It
44 1 must loop and execute forever.
45 1 ------------------------------------------------*/
46 1 input(stud,4) ;/*依此调用自定义函数*/
47 1 aver(stud,4) ;
48 1 order(stud,4) ;
49 1 output(stud,4) ;
50 1 out_row(stud,4) ;
51 1 while (1) {};
52 1 }
53 /* * * * * * * * * * * * * * * * * * * * * * * * * * * */
54 void input(struct stu arr[],int n)
55 {
C51 COMPILER V6.23a MAIN 11/20/2002 18:03:07 PAGE 2
56 1 int i,j;
57 1 char temp[30];
58 1 for (i=0;i<n;i++)
59 1 {
60 2 printf("\nInput Name,Number,English,Mathema,Physic\n");
61 2 gets(arr[i].name,20);
62 2 gets(temp,20);
63 2 arr[i].number=atol(temp);
64 2 for(j=0;j<3;j++)
65 2 {
66 3 gets(temp,20);
67 3 arr[i].score[j]=atoi(temp);
68 3 } ;
69 2 }
70 1 }
71 /* * * * * * * * * * * * * * * * * * * * * * */
72 void aver(struct stu arr[],int n)
73 {
74 1 int i,j;
75 1 for(i=0;i<n;i++)
76 1 {
77 2 arr[i].score[3]=0;
78 2 for(j=0;j<3;j++)
79 2 arr[i].score[3]=arr[i].score[3]+arr[i].score[j];
80 2 arr[i].score[3]=arr[i].score[3]/3;
81 2 }
82 1 }
83 /* * * * * * * * * * * * * * * * * * * * * * */
84 void order(struct stu arr[],int n)
85 {
86 1 struct stu temp;
87 1 int i,j;
88 1 for(i=0;i<n-1;i++)
89 1 for(j=0;j<n-1-i;j++)
90 1 if (arr[j].score[3]>arr[j+1].score[3])
91 1 {temp=arr[j];
92 2 arr[j]=arr[j+1];
93 2 arr[j+1]=temp;
94 2 }
95 1 }
96 /* * * * * * * * * * * * * * * * * */
97 void output(struct stu arr[],int n)
98 {
99 1 int i,j;
100 1 // printf( " * * * * * * * * * * * * * * * * * TABLE* * * * * * * * * * * * * * * * * * \ n " ) ;
101 1 /* delay();
102 1 printf( " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - \ n " ) ;
103 1 delay();
104 1 */ printf("|%10s|%8s|%7s|%7s|%7s|% s|\n","Name","Number","English","mathema","physics","average");
105 1 // printf(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- - - - - \n") ;
106 1 for (i=0;i<n;i++)
107 1 {
108 2 printf("|%10s|%8ld|",arr[i].name,arr[i].number);
109 2 for(j=0;j<4;j++)
110 2 printf("%7.2f|",arr[i].score[j]);
111 2 printf("\n");
112 2 // printf( " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- - - - - \ n " ) ;
113 2 }
114 1 }
C51 COMPILER V6.23a MAIN 11/20/2002 18:03:07 PAGE 3
115 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
116 void out_row(struct stu arr[],int n)
117 {
118 1 float row[4]={0,0,0,0};
119 1 int i,j;
120 1 for(i=0;i<4;i++)
121 1 {
122 2 for(j=0;j<n;j++)
123 2 row[i]=row[i]+arr[j].score[i];
124 2 row[i]=row[i]/n;
125 2 }
126 1 printf("|%19c|",' ');
127 1 for (i=0;i<4;i++)
128 1 printf("%7.2f|",row[i]) ;
129 1 printf("\n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ n") ;
130 1 }
131
132
133 /*void delay()
134 {
135 int i;
136 for(i=2000;i>0;i--);
137 }
138 */
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 2058 ----
CONSTANT SIZE = 248 ----
XDATA SIZE = ---- 291
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -