![]() |
#2
wuxia1111112012-12-23 22:56
void band()
{ fp2 = fopen( "b.txt", "r" ); int band[8][11]; int choice;//声明 printf( "请选择:\n" ); printf( "\t\t\t1--高数\n\t\t\t2--工图\n\t\t\t3--英语\n\t\t\t4--C语言\n\t\t\t5--航概\n\t\t\t6--体育\n\t\t\t7--思修\n" ); scanf( "%d", &choice ); for( i = 1 ; i <= 7; i++ ) if( choice == i ){ for( j = 1; j <= 7 ; j++ ) for( i = 1;i <= 10; i++) band[j][i] = 0; for( i = 1; i <= 20; i++ ) for( j = 1; j <= 7; j++ ){ if( stu[i].cj[j] <= 10 ) band[j][1]++; else if( stu[i].cj[j] <= 20 ) band[j][2]++; else if( stu[i].cj[j] <= 30 ) band[j][3]++; else if( stu[i].cj[j] <= 40 ) band[j][4]++; else if( stu[i].cj[j] <= 50 ) band[j][5]++; else if( stu[i].cj[j] <= 60 ) band[j][6]++; else if( stu[i].cj[j] <= 70 ) band[j][7]++; else if( stu[i].cj[j] <= 80 ) band[j][8]++; else if( stu[i].cj[j] <= 90 ) band[j][9]++; else band[j][10]++; } } for( j = 1; j <= 10; j++ ) printf( "分数段在0--%d的人数有:%d\n", 10*j, band[i][j] ); }//这的逗号应该不要吧 你试试哦! |
void band()
{
fp2 = fopen( "b.txt", "r" );
int band[8][11];
printf( "请选择:\n" );
printf( "\t\t\t1--高数\n\t\t\t2--工图\n\t\t\t3--英语\n\t\t\t4--C语言\n\t\t\t5--航概\n\t\t\t6--体育\n\t\t\t7--思修\n" );
scanf( "%d", &choice );
for( i = 1 ; i <= 7; i++ )
if( choice == i ){
for( j = 1; j <= 7 ; j++ )
for( i = 1;i <= 10; i++)
band[j][i] = 0;
for( i = 1; i <= 20; i++ )
for( j = 1; j <= 7; j++ ){
if( stu[i].cj[j] <= 10 )
band[j][1]++;
else if( stu[i].cj[j] <= 20 )
band[j][2]++;
else if( stu[i].cj[j] <= 30 )
band[j][3]++;
else if( stu[i].cj[j] <= 40 )
band[j][4]++;
else if( stu[i].cj[j] <= 50 )
band[j][5]++;
else if( stu[i].cj[j] <= 60 )
band[j][6]++;
else if( stu[i].cj[j] <= 70 )
band[j][7]++;
else if( stu[i].cj[j] <= 80 )
band[j][8]++;
else if( stu[i].cj[j] <= 90 )
band[j][9]++;
else band[j][10]++;
}
}
for( j = 1; j <= 10; j++ )
printf( "分数段在0--%d的人数有:%d\n", 10*j, band[i][j] );
};