C语言编程的问题!!!!!求高手指点!!!指出我错在哪....><
#include<iostream>#include<string>usingnamespacestd;intmain(){inta[7]={75,80,83,85,86...
#include<iostream>
#include<string>
using namespace std;
int main()
{
int a[7]={75,80,83,85,86,30,0};
string name[7]={"数学","物理","外语","体育","人数","平均成绩","最低分数的科目"};
char*MeanLow[]={"人数","平均成绩","最低分数科目的成绩","最低分数的科目"};
int averageG=0;
for(int=0;i<5;i++);
{
averageG+=a[i];
}
averageG/=5;
int minNum=0,gradeMin=100;
for(int i=0;i<5;i++);
{
if(a[i]<gradeMin)
{
gradeMin=a[i];
minNum=i;
}
}
cout<<"原始信息如下:"<<endl;
for (int i=0;i<7;i++);
{
cout<<name[i]<<":"<<a[i]<<endl;
}
cout<<"最低分数的科目:"<<endl
<<endl<<"全班各科平均成绩如下:"<<endl;
for (int i=0;i<5;i++);
{
cout<<name[i]<<":"<<a[i]<<endl;
}
cout<<"统计结果如下:"<<endl;
cout<<MeanLow[0]<<":"<<a[5]<<endl;
cout<<MeanLow[1]<<":"<<averageG<<endl;
cout<<MeanLow[2]<<":"<<gradeMin<<endl;
cout<<MeanLow[3]<<":"<<name[minNum]<<endl;
return 0;
}
Compiling...
Cpp1.cpp
D:\ll\Cpp1.cpp(10) : error C2513: 'int' : no variable declared before '='
D:\ll\Cpp1.cpp(10) : error C2065: 'i' : undeclared identifier
D:\ll\Cpp1.cpp(25) : error C2374: 'i' : redefinition; multiple initialization
D:\ll\Cpp1.cpp(16) : see declaration of 'i'
D:\ll\Cpp1.cpp(31) : error C2374: 'i' : redefinition; multiple initialization
D:\ll\Cpp1.cpp(16) : see declaration of 'i'
Error executing cl.exe.
出现这四个问题,,请帮忙解决一下。。 展开
#include<string>
using namespace std;
int main()
{
int a[7]={75,80,83,85,86,30,0};
string name[7]={"数学","物理","外语","体育","人数","平均成绩","最低分数的科目"};
char*MeanLow[]={"人数","平均成绩","最低分数科目的成绩","最低分数的科目"};
int averageG=0;
for(int=0;i<5;i++);
{
averageG+=a[i];
}
averageG/=5;
int minNum=0,gradeMin=100;
for(int i=0;i<5;i++);
{
if(a[i]<gradeMin)
{
gradeMin=a[i];
minNum=i;
}
}
cout<<"原始信息如下:"<<endl;
for (int i=0;i<7;i++);
{
cout<<name[i]<<":"<<a[i]<<endl;
}
cout<<"最低分数的科目:"<<endl
<<endl<<"全班各科平均成绩如下:"<<endl;
for (int i=0;i<5;i++);
{
cout<<name[i]<<":"<<a[i]<<endl;
}
cout<<"统计结果如下:"<<endl;
cout<<MeanLow[0]<<":"<<a[5]<<endl;
cout<<MeanLow[1]<<":"<<averageG<<endl;
cout<<MeanLow[2]<<":"<<gradeMin<<endl;
cout<<MeanLow[3]<<":"<<name[minNum]<<endl;
return 0;
}
Compiling...
Cpp1.cpp
D:\ll\Cpp1.cpp(10) : error C2513: 'int' : no variable declared before '='
D:\ll\Cpp1.cpp(10) : error C2065: 'i' : undeclared identifier
D:\ll\Cpp1.cpp(25) : error C2374: 'i' : redefinition; multiple initialization
D:\ll\Cpp1.cpp(16) : see declaration of 'i'
D:\ll\Cpp1.cpp(31) : error C2374: 'i' : redefinition; multiple initialization
D:\ll\Cpp1.cpp(16) : see declaration of 'i'
Error executing cl.exe.
出现这四个问题,,请帮忙解决一下。。 展开
5个回答
展开全部
#include<iostream>
#include<string>
using namespace std;
int main()
{
int a[7]={75,80,83,85,86,30,0};
string name[7]={"数学","物理","外语","体育","人数","平均成绩","最低分数的科目"};
char*MeanLow[]={"人数","平均成绩","最低分数科目的成绩","最低分数的科目"};
int averageG=0;
for(int=0;i<5;i++);//少了 i ,多了;
{
averageG+=a[i];
}
averageG/=5;
int minNum=0,gradeMin=100;
for(int i=0;i<5;i++); //多了;
{
if(a[i]<gradeMin)
{
gradeMin=a[i];
minNum=i;
}
}
cout<<"原始信息如下:"<<endl;
for (int i=0;i<7;i++); //多了;
{
cout<<name[i]<<":"<<a[i]<<endl;
}
cout<<"最低分数的科目:"<<endl
<<endl<<"全班各科平均成绩如下:"<<endl;
for (int i=0;i<5;i++); //多了;
{
cout<<name[i]<<":"<<a[i]<<endl;
}
cout<<"统计结果如下:"<<endl;
cout<<MeanLow[0]<<":"<<a[5]<<endl;
cout<<MeanLow[1]<<":"<<averageG<<endl;
cout<<MeanLow[2]<<":"<<gradeMin<<endl;
cout<<MeanLow[3]<<":"<<name[minNum]<<endl;
return 0;
}
#include<string>
using namespace std;
int main()
{
int a[7]={75,80,83,85,86,30,0};
string name[7]={"数学","物理","外语","体育","人数","平均成绩","最低分数的科目"};
char*MeanLow[]={"人数","平均成绩","最低分数科目的成绩","最低分数的科目"};
int averageG=0;
for(int=0;i<5;i++);//少了 i ,多了;
{
averageG+=a[i];
}
averageG/=5;
int minNum=0,gradeMin=100;
for(int i=0;i<5;i++); //多了;
{
if(a[i]<gradeMin)
{
gradeMin=a[i];
minNum=i;
}
}
cout<<"原始信息如下:"<<endl;
for (int i=0;i<7;i++); //多了;
{
cout<<name[i]<<":"<<a[i]<<endl;
}
cout<<"最低分数的科目:"<<endl
<<endl<<"全班各科平均成绩如下:"<<endl;
for (int i=0;i<5;i++); //多了;
{
cout<<name[i]<<":"<<a[i]<<endl;
}
cout<<"统计结果如下:"<<endl;
cout<<MeanLow[0]<<":"<<a[5]<<endl;
cout<<MeanLow[1]<<":"<<averageG<<endl;
cout<<MeanLow[2]<<":"<<gradeMin<<endl;
cout<<MeanLow[3]<<":"<<name[minNum]<<endl;
return 0;
}
更多追问追答
追问
但是我把你说的都改了,还是有三个错误呀。。
追答
// 123.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include<string>
using namespace std;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a[7]={75,80,83,85,86,30,0};
string name[7]={"数学","物理","外语","体育","人数","平均成绩","最低分数的科目"};
char*MeanLow[]={"人数","平均成绩","最低分数科目的成绩","最低分数的科目"};
int averageG=0;
for(int i=0;i<5;i++)//少了 i ,多了;
{
averageG += a[i];
}
averageG/=5;
int minNum=0,gradeMin=100;
for(int i=0;i<5;i++) //多了;
{
if(a[i]<gradeMin)
{
gradeMin=a[i];
minNum=i;
}
}
cout<<"原始信息如下:"<<endl;
for (int i=0;i<7;i++) //多了;
{
cout<<name[i]<<":"<<a[i]<<endl;
}
cout<<"最低分数的科目:"<<endl
<<endl<<"全班各科平均成绩如下:"<<endl;
for (int i=0;i<5;i++) //多了;
{
cout<<name[i]<<":"<<a[i]<<endl;
}
cout<<"统计结果如下:"<<endl;
cout<<MeanLow[0]<<":"<<a[5]<<endl;
cout<<MeanLow[1]<<":"<<averageG<<endl;
cout<<MeanLow[2]<<":"<<gradeMin<<endl;
cout<<MeanLow[3]<<":"<<name[minNum]<<endl;
getchar();
return 0;
}
还有什么错,我改了之后 ,没有问题呀
展开全部
for(int=0;i<5;i++);
应为
for(int i=0;i<5;i++)
后面的for循环语句最后都多了分号
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
for(int=0;i<5;i++); ----- 改为for(int i =0;i<5;i++) // 少了i, 多了;
for(int i=0;i<5;i++); --- for循环后不要加;
for(int i=0;i<5;i++); --- for循环后不要加;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
for(int i=0;i<5;i++);
追问
但是还是有错误啊。。~~~~(>_<)~~~~
追答
上面有人给你回答了,很简单的错误,语法上就是这几个错误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-30
展开全部
你还是把编译出错的代码贴上来吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询