note

cout&cin

  1. input:
#include <iostream>
#include <cstdlib>
using namespace std;
int main(void)
{
   int num1 = 5, num2 = 3;

   cout << "I love C++." << endl << "You love C++, too.\n"; //endl等價於\n
   cout << "We all love C++." << "\n";
   cout << " I have "<< num1 <<" books."<<endl;
   cout << "We have "<<(num1+num2)<<" books. "<<endl;
}
  1. output:
I love C++.
You love C++, too.
We all love C++.
 I have 5 books.
We have 8 books.

  1. intput:
#include <iostream>
#include <cstdlib>
using namespace std;
int main(void)
{
   int x, y;

   cout << "Input frist integer: ";
   cin >> x;                                //讀取鍵盤中的整數,並存放
   cout << "Input second integer: ";
   cin >> y;
   cout << x <<"+"<< y <<"="<< x+y <<endl;  //兩數相加

   cout << "Input two integer: ";
   cin >> x >> y;                           //連續輸入兩個
   cout << x <<"+"<< y <<"="<< x+y <<endl;  //兩數相加
   system("pause");
   return 0;
}
  1. output:
Input frist integer: 1
Input second integer: 2
1+2=3
Input two integer: 3 4
3+4=7
請按任意鍵繼續 . . .

math.h

int *ptr, num = 20;
ptr = &num

// ptr是值(*ptr)的位置,&num是值(num)的位置
#include <bits/stdc++.h>

using namespace std;

int main()
{

}