小问题求助
(请问大神为什么我的name的名字不显示!)#include<iostream.h>
void main()
{
int data = {{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;
}
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;
}
average = a/4;
cout <<"各科成绩平均值:"<<average<<endl;
average=0;
a=0;
}
} #include<iostream>
#include<string>
using namespace std;
void main()
{
int data = {{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;
}
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;
}
average = a/4;
cout <<"各科成绩平均值:"<<average<<endl;
average=0;
a=0;
}
}
嗯嗯,谢谢
页:
[1]