C++ 入门 控制台输入输出

1.控制台输出 hello world

#include "stdafx.h"
#include<iostream>

using namespace std;
int main()
{
    cout << "Hello world ! ";
    system("pause");
    return 0;
}

2.交互小程序 加法计算

using namespace std;
int main()
{
    int a, b;
    cout << "计算 a + b = ? " << endl;
    cout << "Please enter \"a\"" << endl;
    cin >> a;
    cout << "Please enter \" b \"" << endl;
    cin >> b;
    cout << a <<" + "<< b << " = " << a + b  << endl;
    system("pause");
    return 0;
}

 

posted @ 2017-07-04 18:21  皓琪  Views(15660)  Comments(0)    收藏  举报