要使用cin和cout,必须使用预处理指令
#include<iostream>
如果没有using namespace std,标识符应为std::cin和std::cout
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
cout << "Enter two numbers:" << endl;
int v1, v2;
cin >> v1 >> v2;
cout << "The sum of" << v1 << "and" << v2
<< "is" << v1 + v2 <<endl;
system("pause");
return 0;
}
或者#include<iostream>
#include<stdio.h>
int main()
{
std::cout << "Enter two numbers:" << std::endl;
int v1, v2;
std::cin >> v1 >> v2;
std::cout << "The sum of" << v1 << "and" << v2
<< "is" << v1 + v2 << std::endl;
system("pause");
return 0;
}