Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<time.h>
- #define MAX 50
- struct BasReq{
- int StudID; // nine digits
- int W[10]; // grade of week i
- float BasR; // average from W[0] ~ W[9]
- };
- int main()
- {
- float sum=0;
- srand(time(NULL));
- BasReq BR[MAX]={
- {499410001,{0},0},
- {499410002,{0},0},
- {499410003,{0},0},};
- for (int i=0;i<3;i++)
- {
- for (int j=0;j<10;j++)
- {
- BR[i].W[j] = rand()%100;
- sum += BR[i].W[j];
- }
- BR[i].BasR = sum/10;
- sum = 0;
- }
- printf(" ID BasR W01 W02 W03 W04 W05 W06 W07 W08 W09 W10\n");
- printf("--------------------------------------------------------------------\n");
- for (int i=0;i<3;i++)
- {
- printf(" %d %2.1f ", BR[i].StudID, BR[i].BasR);
- for (int j=0;j<10;j++)
- {
- printf("%02d ", BR[i].W[j]);
- }
- printf("\n");
- }
- system("pause");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement