1. 程式人生 > >C++ 入門小程序

C++ 入門小程序

color name hello namespace world ios urn use pan

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++ 入門小程序