永发信息网

C++a+b=几的源代码

答案:4  悬赏:30  手机版
解决时间 2021-02-13 17:47
  • 提问者网友:疯孩纸
  • 2021-02-12 20:14
..小弟刚学C++对于声明变量有点晕 求高手指点
最佳答案
  • 五星知识达人网友:长青诗
  • 2021-02-12 21:47
是的,他的代码编译会有一个问题,你需要在代码最开始的地方包含
#include "stdafx.h"
也就是完整代码如下;
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int a;
cout<<"请输入a的值:a=";
cin>>a;
int b;
cout<<"请输入b的值:b=";
cin>>b;
cout<<"a+b="<<a+b<<endl;
return 0;}
全部回答
  • 1楼网友:神鬼未生
  • 2021-02-12 23:56
#include <iostream> using namespace std; int main() { int a; int b; cin>>a>>b; cout<<a+b<<endl; return 0; }
  • 2楼网友:梦中风几里
  • 2021-02-12 23:22
#include &lt;iostream.h&gt; int main() { int a,b; //声明变量a,b 为整型 cin&gt;&gt;a&gt;&gt;b; //输入a,b的值 cout&lt;&lt;&quot;和为:\n&quot;&lt;&lt;a+b&lt;&lt;endl; //在屏幕上输出 return 0; }
  • 3楼网友:慢性怪人
  • 2021-02-12 23:09
#include <iostream> using namespace std; int main() { int a; cout<<"请输入a的值:a="; cin>>a; int b; cout<<"请输入b的值:b="; cin>>b; cout<<"a+b="<<a+b<<endl; return 0;}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯