用VS2008编译C++的时候系统提示【1>e:\我的程序\ilove\ilove\main.cpp(3) : fatal error C1083: 无法打开包括文件:“iostream.h”: No such file or directory】应该怎样修改呀?
程序段
#include "stdafx.h"
#include<iostream.h>
int main()
{
char *name,*num;
float score[3];
float StuAve[20];
bool flag;
cout<<"请输入要处理学生的个数:"<<endl;
int m;
float temp;
student stu[20];
cout<<"请输入学生的个数";
cin>>m;
for(int n=0;n<m;n++)
{
cin>>name>>",">>num>>",">>score[3];
}
for(n=0;n<m;n++)
{
flag=false;
for(int j=m;j>0;j--)
if(stu[j].getStuAve()>stu[j-1].getStuAve())
{
temp=stu[j].getStuAve();
stu[j].getStuAve()=stu[j-1].getStuAve();
stu[j-1].getStuAve()=temp;
flag=true;
}
if(!flag)
break;
}
cout<<"成绩最好的学生的成绩是:"<<StuAve(float stu[0].getStuAve());
float sum0,sum1,sum2;
for(n=0;n<m;n++)
{
sum0+=stu[n].getscore(score[0]);
sum1+=stu[n].getscore(score[1]);
sum2+=stu[n].getscore(score[2]);
}
float couScore1,couScore2,couScore3;
couScore1=sum0/m;
couScore2=sum1/m;
couScore3=sum2/m;
cout<<"每门课程的平均分数为:"<<couScore1<<" "<<couScore2<<" "<<couScore3<<endl;
return 0;
}
#include<iostream.h>
int main()
{
char *name,*num;
float score[3];
float StuAve[20];
bool flag;
cout<<"请输入要处理学生的个数:"<<endl;
int m;
float temp;
student stu[20];
cout<<"请输入学生的个数";
cin>>m;
for(int n=0;n<m;n++)
{
cin>>name>>",">>num>>",">>score[3];
}
for(n=0;n<m;n++)
{
flag=false;
for(int j=m;j>0;j--)
if(stu[j].getStuAve()>stu[j-1].getStuAve())
{
temp=stu[j].getStuAve();
stu[j].getStuAve()=stu[j-1].getStuAve();
stu[j-1].getStuAve()=temp;
flag=true;
}
if(!flag)
break;
}
cout<<"成绩最好的学生的成绩是:"<<StuAve(float stu[0].getStuAve());
float sum0,sum1,sum2;
for(n=0;n<m;n++)
{
sum0+=stu[n].getscore(score[0]);
sum1+=stu[n].getscore(score[1]);
sum2+=stu[n].getscore(score[2]);
}
float couScore1,couScore2,couScore3;
couScore1=sum0/m;
couScore2=sum1/m;
couScore3=sum2/m;
cout<<"每门课程的平均分数为:"<<couScore1<<" "<<couScore2<<" "<<couScore3<<endl;
return 0;
}
=====================================================================
o 2008 和win7系统本身存在不兼容性问题。很多程序不能运行也是很正常的,这是微软做的不好的地方。当然也有可能是软件安装的问题。如果你确信软件安装没问题的话,那就是不兼容性问题了。
我的建议是:如果你真想好好学C++的话,建议去装XP系统。win7系统存在很多问题,不仅和visual studio 2008 存在兼容性问题,而且和如wince系统等软件都存在兼容性问题。我买的电脑是thinkpad的,自带的也是win7正版系统,现在已经重装XP系统了。
还有你给的代码例子也不太好,见如下分析:
#include <iostream.h>
main()
{
cout<<"fbdsfkj"<<endl;
}
代码是没有问题,但是上面这种编法是很不好的编程风格,混合了C和C++,在VC6.0下可以编译运行,但这样写不好。好的C++写法应是:
#include <iostream>
using namespace std;
int main()
{
cout<<"fbdsfkj"<<endl;
return 0;
}
main()
{
cout<<"fbdsfkj"<<endl;
}
代码是没有问题,但是上面这种编法是很不好的编程风格,混合了C和C++,在VC6.0下可以编译运行,但这样写不好。好的C++写法应是:
#include <iostream>
using namespace std;
int main()
{
cout<<"fbdsfkj"<<endl;
return 0;
}
=====================================================================
楼主看的书太老了。
新标准98年就出来了,你看的书还在讲98年前的C++,换一本吧。
新标准98年就出来了,你看的书还在讲98年前的C++,换一本吧。
=====================================================================
把使用#include <iostream.h>
都换成
#include <iostream>
using namespace std;
都换成
#include <iostream>
using namespace std;
=====================================================================
#include <iostream>
using namespace std;
2005好多东西都不用了,像什么.h的头文件基本抛弃了,即使能用也一堆警告
using namespace std;
2005好多东西都不用了,像什么.h的头文件基本抛弃了,即使能用也一堆警告
steedhorse 发表于:2007-11-27 00:18:23 4楼
楼主看的书太老了。
新标准98年就出来了,你看的书还在讲98年前的C++,换一本吧。
好像是噢,我现在用的是《面向对象的理论与C++实践》,清华出版的,第一版时间是97年
请推荐一本书,万分感激
楼主看的书太老了。
新标准98年就出来了,你看的书还在讲98年前的C++,换一本吧。
=====================================================================
好像是噢,我现在用的是《面向对象的理论与C++实践》,清华出版的,第一版时间是97年
请推荐一本书,万分感激
=====================================================================
<<C++ Primer 5nd>> C++学习 强烈推荐
=====================================================================
#include <iostream>
using namespace std;
int main()
{
// 实现
return 0;
}
using namespace std;
int main()
{
// 实现
return 0;
}
ANSI/ISO C++
=====================================================================
#include <iostream.h>
过时的标准,该改改啦 ^_^ VC2003就已经开始不支持了
过时的标准,该改改啦 ^_^ VC2003就已经开始不支持了
=====================================================================
#include <iostream>
using namespace std;
//struct my
class my
{
public:
int x;
int y;
int output()
{
cout<<x<<endl<<y <<endl;
return 0;
}
};
int main()
{
my pt;
pt.x =5;
pt.y =5;
//cout<<pt.y <<endl<<pt.y <<endl;
pt.output();
getchar();
return 0;
}
using namespace std;
//struct my
class my
{
public:
int x;
int y;
int output()
{
cout<<x<<endl<<y <<endl;
return 0;
}
};
int main()
{
my pt;
pt.x =5;
pt.y =5;
//cout<<pt.y <<endl<<pt.y <<endl;
pt.output();
getchar();
return 0;
}