沈阳华东物资回收中心:请问我的程序哪里错了.

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 20:15:06
#include <iostream>
using namespace std;
int main()
{
cout<<"enter x and y:";
cin>>x>>y;
if(x!=y)
if(x>y)
cout<<"x>y"<<endl;
else
cout<<"x<y"<<endl;
else
cout<<"x=y"<<endl;
}

#include <iostream>
using namespace std;
int main()
{
int x,y;
cout<<"enter x and y:";
cin>>x>>y;
if(x!=y)
if(x>y)
cout<<"x>y"<<endl;
else
cout<<"x<y"<<endl;
else
cout<<"x=y"<<endl;
}

你再试试

x,y还没声明呢
int x,y;

#include <iostream>
using namespace std;
int main()
{
  int x,y;
  cout<<"enter x and y:";
  cin>>x>>y;
  if(x!=y)
  {
    if(x>y)
      cout<<"x>y"<<endl;
    else
      cout<<"x<y"<<endl;
  }
  else
  cout<<"x=y"<<endl;
  return 0;
}