首页 > 代码库 > C++ 入门小程序

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;
}

3.

C++ 入门小程序