第1个回答 2010-07-11
#include <iostream.h>
using namespace std;
这两行不能同时存在,以 .h 结尾的旧版本 C++ 库文件没有 namespace
最好按较新的标准来写
#include <iostream>
using namespace std;
第2个回答 2010-07-11
如果用标准模板库的话就不要再头文件后面加.h
最后的一行语句改成return 0;
调试成功的代码:
#include<iostream>
using namespace std;
int main()
{
int num,count1=0,count2=0;
double sum=0.0,ave=0.0;
cout<<"请输入若干整数,以0结束:\n";
cin >>num;
while(num!=0)
{
sum=sum+num;
if(num>0)
count1++;
else
count2++;
cin>>num;
}
if((count1+count2)!=0)
{
ave=sum/(count1+count2);
cout<<"和为:"<<sum<<'\t'<<"平均值为:"<<ave;
cout<<"\n正整数有:"<<count1<<"个!\n"<<"负整数有:"<<count2<<"个!\n";
}
else
cout<<"没有输入有效数字";
return 0;
}
第3个回答 2010-07-11
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
d:\prog\vc6\test1\cpp1.cpp(3) : error C2871: 'std' : does not exist or is not a namespace
d:\prog\vc6\test1\cpp1.cpp(27) : error C2065: 'reture0' : undeclared identifier
d:\prog\vc6\test1\cpp1.cpp(28) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.
Cpp1.obj - 1 error(s), 0 warning(s)
一般你看到的是Cpp1.obj - 1 error(s), 0 warning(s)
其实向上拉还有东西。。。
第4个回答 2010-07-11
#include<iostream.h>把.h去掉,它和std相冲突,return 0;不是reture0;这种关键字在c++6.0中显示为蓝色字体,当显示错误时,你把提示错误的窗口框的滚动条向上拉,提示错误点是什么,当你双击这一行时,在程序体中会有一个闪动的蓝色箭头指向该行,方便你找出错误点.
第5个回答 2010-07-11
VC6.0中应该#include <iostream>
using namespace std;
另外,你的return 0;应该这样