|
发表于 2017-9-24 22:25:48
From FishC Mobile
|
显示全部楼层
|阅读模式
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
(请问大神为什么我的name的名字不显示!)
#include<iostream.h>
void main()
{
int data[4][4] = {{19,27,36,48},{5,45,56,56},{56,85,42,96},{56,82,84,35}};
string name;
int num = 0,i,j,average,a=0,max=0;
for (j=0; j<=3; j++)
{ for (i=0; i<=3; i++)
{ num = num + data[i][j];
}
if (j==0)
{name ="小明";}
else if(j==1)
{name="小红";}
else if(j==2)
{name="小强";}
else if (j ==3)
{name="小华";}
cout << name<<"成绩之和:"<<num<<endl;
if (num>max)
{max=num;}
num=0;
}
cout <<"成绩之和最好为"<<max<<endl;
for (i=0; i<=3; i++)
{ for (j=0; j<=3; j++)
{a= a + data[i][j];
}
average = a/4;
cout <<"各科成绩平均值:"<<average<<endl;
average=0;
a=0;
}
}
#include<iostream>
#include<string>
using namespace std;
void main()
{
int data[4][4] = {{19,27,36,48},{5,45,56,56},{56,85,42,96},{56,82,84,35}};
string name;
int num = 0,i,j,average,a=0,max=0;
for (j=0; j<=3; j++)
{ for (i=0; i<=3; i++)
{ num = num + data[i][j];
}
if (j==0)
{name ="小明";}
else if(j==1)
{name="小红";}
else if(j==2)
{name="小强";}
else if (j ==3)
{name="小华";}
cout<<name<<"成绩之和:"<<num<<endl;
if (num>max)
{max=num;}
num=0;
}
cout <<"成绩之和最好为"<<max<<endl;
for (i=0; i<=3; i++)
{ for (j=0; j<=3; j++)
{a= a + data[i][j];
}
average = a/4;
cout <<"各科成绩平均值:"<<average<<endl;
average=0;
a=0;
}
}
|
|