C++ 不使用 vector 头文件实现学生成绩统计 - 寻找学习小状元
#include\x20
using\x20namespace\x20std;
int\x20main()\x20{ \x20\x20int\x20N; \x20\x20cin\x20>>\x20N; \x20\x20string\x20names[N]; \x20\x20int\x20scores[N][4]; \x20\x20int\x20totals[N];
\x20\x20for\x20(int\x20i\x20=\x200;\x20i\x20<\x20N;\x20i++)\x20{ \x20\x20\x20\x20cin\x20>>\x20names[i]; \x20\x20\x20\x20for\x20(int\x20j\x20=\x200;\x20j\x20<\x204;\x20j++)\x20{ \x20\x20\x20\x20\x20\x20cin\x20>>\x20scores[i][j]; \x20\x20\x20\x20} \x20\x20}
\x20\x20int\x20maxTotal\x20=\x200; \x20\x20string\x20topStudent; \x20\x20int\x20maxScore\x20=\x20scores[0][0]; \x20\x20int\x20minScore\x20=\x20scores[0][0];
\x20\x20for\x20(int\x20i\x20=\x200;\x20i\x20<\x20N;\x20i++)\x20{ \x20\x20\x20\x20int\x20total\x20=\x200; \x20\x20\x20\x20for\x20(int\x20j\x20=\x200;\x20j\x20<\x204;\x20j++)\x20{ \x20\x20\x20\x20\x20\x20total\x20+=\x20scores[i][j]; \x20\x20\x20\x20\x20\x20if\x20(scores[i][j]\x20>\x20maxScore)\x20{ \x20\x20\x20\x20\x20\x20\x20\x20maxScore\x20=\x20scores[i][j]; \x20\x20\x20\x20\x20\x20} \x20\x20\x20\x20\x20\x20if\x20(scores[i][j]\x20<\x20minScore)\x20{ \x20\x20\x20\x20\x20\x20\x20\x20minScore\x20=\x20scores[i][j]; \x20\x20\x20\x20\x20\x20} \x20\x20\x20\x20} \x20\x20\x20\x20totals[i]\x20=\x20total; \x20\x20\x20\x20if\x20(total\x20>\x20maxTotal)\x20{ \x20\x20\x20\x20\x20\x20maxTotal\x20=\x20total; \x20\x20\x20\x20\x20\x20topStudent\x20=\x20names[i]; \x20\x20\x20\x20} \x20\x20}
\x20\x20for\x20(int\x20i\x20=\x200;\x20i\x20<\x20N;\x20i++)\x20{ \x20\x20\x20\x20cout\x20<<\x20totals[i]\x20<<\x20endl; \x20\x20} \x20\x20cout\x20<<\x20topStudent\x20<<\x20endl; \x20\x20cout\x20<<\x20maxScore\x20<<\x20"\x20"\x20<<\x20minScore\x20<<\x20endl;
\x20\x20return\x200; }
原文地址: https://www.cveoy.top/t/topic/pE1z 著作权归作者所有。请勿转载和采集!