游客 Signup | Login
中文 | En

4000 - 变量实验1.cpp

让我们设想这样一个例子,我要求你在脑子里记住5这个数字,然后再记住2这个数字。你已经存储了两个数值在你的记忆里。现在我要求你在我说的第一个数值上加1,你应该保留6 (即5+1)和2在你的记忆里。现在如果我们将两数相减可以得到结果4。

所有这些你在脑子里做的事情与计算机用两个变量可以做的事情非常相似。同样的处理过程用C++来表示可以写成下面一段代码:

请提交以下代码

Input

Output

Examples

Input

no input needed

Output

a=6
result=4

Solution C++

//变量实验1.cpp
#include <iostream>
using namespace std;
int main ()
{
  int a;
  int b;
  int result;

  a = 5;
  b = 2;
  a = a + 1;
  result = a - b;

  cout<<"a="<<a<<endl;
  cout<<"result="<<result<<endl;
  return 0; 
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题