简单的一个问题,求找错

#include<iostream>

using namespace std;

void main()

{

int x;

if(cin>>x>>1)

cout<<"szutic";

else

cout<<"你好,深圳大学";

}


有志青年P
浏览 1942回答 4
4回答

onemoo

char x = '\0'; cin >> x; if (x == '1')     cout << "szutic" << endl; else     cout << "你好" << endl;

有志青年P

我的vc++6.0只会报错误的数量不知道在哪错了这个是慕课的报错error: iostream: No such file or directory error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace' In function 'main': error: 'cin' undeclared (first use in this function) error: (Each undeclared identifier is reported only once error: for each function it appears in.) error: 'cout' undeclared (first use in this function) error: 'endl' undeclared (first use in this function) warning: no newline at end of file

onemoo

首先,main函数应该声明为 int main()  ,不存在返回类型为void的声明。if语句括号中最后那个1是字面常量,不能被写入值

辛运之旅

既然main函数是无返回值 ,那么return 0;就是多余的了。而且cin>>x>>1 这句看不懂
打开App,查看更多内容
随时随地看视频慕课网APP