C++有空的进来

来源:百度知道 编辑:UC知道 时间:2024/04/27 17:14:39
#include<iostream.h>
int main()
cout << "计算两个数之间的和 :" ;
bool bAgain ;
char cAnswer ;
do {
int nStart, nEnd ;
cout <<"输入一个较小的整数: " ;
cin >>nStart ;
cout <<"较大的一个 :" ;
cin >>nEnd ;
int nResult = 0;
for (; nStart < nEnd ; nStart += 2, nResult += nStart) ;
cout <<"两个数之和:" <<nResult <<endl ;
cout <<"你还要计算吗? \n" ;
cout <<"请输入'y' 或'n'\n;
cin >>cAnswer ;
bAgain =( cAnswer == 'y')?1 : 0;
}
while (bAgain);
return 0;
}

f:\vb\msdev98\myprojects\for于switch镶嵌\for于switch镶嵌.cpp(3) : error C2146: syntax error : missing ';' before identifier 'cout'
f:\vb\msdev98\myprojects\for于switch镶嵌\for于switch镶嵌.cpp(3) : fatal error C1004: unexpected end of file found

int main() //后面少个{

cout <<"请输入'y' 或'n'\n; //少个"

main 后面少了一个{

#include<iostream.h>
main()
{
int cout << "计算两个数之间的和 :" ;
bool bAgain ;
char cAnswer ;
do
{ int nStart, nEnd ;
int cout <<"输入一个较小的整数: " ;
cin >>nStart ;
cout <<"较大的一个 :" ;
cin >>nEnd ;
int nResult = 0;
for (; nStart < nEnd ; nStart += 2, nResult += nStart) ;
cout <<"两个数之和:" <<nResult <<endl ;
cout <<"你还要计算吗? \n" ;
cout <<"请输入'y' 或'n'\n;
cin >>cAnswer ;
bAgain =( cAnswer == 'y')?1 : 0;
}
while (bAgain);
return 0;
}
不知道这样可以不,你可以试下。