|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include<iostream>
- using namespace std;
- main()
- {
- int stu[10][3] = {{87,96,70},{68,87,90},{94,100,90},
- {100,81,82},{83,65,85},{78,87,65},
- {85,75,83},{91,94,100},{76,72,84},{87,93,73}
-
- };
-
- int fre[11] = {0};
- for(int q = 0;q <= 10;q++)
- {
- cout<<fre[q]<<endl;
- }
-
- for(int i = 0 ;i <= 9;i++)
- {
- for(int x = 0 ;x <= 9;x++)
- {
- for(int y = 0;y <=2;y++)
- {
- if ((i*10 <= stu[x][y]) && (stu[x][y] <= i*10 +9))
- {
- ++fre[i];
- cout<<" +1 ";
- }
- if (stu[x][y] == 100)
- {
- ++fre[10];cout<<" +2 ";
- }
-
- }
- }
-
- }
-
- for(int q = 0;q <= 10;q++)
- {
- cout<<fre[q]<<endl;
- }
-
- }
复制代码
为啥输出fre[10]是30
#include<iostream>
using namespace std;
main()
{
int stu[10][3] = {{87,96,70},{68,87,90},{94,100,90},
{100,81,82},{83,65,85},{78,87,65},
{85,75,83},{91,94,100},{76,72,84},{87,93,73}
};
int fre[11] = {0};
for(int q = 0;q <= 10;q++)
{
cout<<fre[q]<<endl;
}
for(int x = 0 ;x <= 9;x++)
{
for(int y = 0;y <=2;y++)
{
int k=stu[x][y]/10;
fre[k]++;
if (k<10)
{
cout<<" +1 ";
}
if (k==10)
{
cout<<" +2 ";
}
}
}
for(int q = 0;q <= 10;q++)
{
cout<<fre[q]<<endl;
}
}
|
|