- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int z[20], a, b, c;
- cout << "請輸入first個數字:" ;
- cin >> z[0];
- cout << "請輸入second個數字:" ;
- cin >> z[1];
- a = (z[1] > z[0])? z[1] : z[0];
- b = (z[1] < z[0])? z[1] : z[0];
- c = a - b;
- cout << "等差為" << a - b << endl;
- cout << "編號" << "\t" << "內容" << endl;
- for (int i = 0; i < 20; i++)
- {
- z[i+1] = z[i] + c;
- }
- for (int i = 0; i < 20; i++)
- {
- cout << i << "\t" << z[i] << endl;
- }
- system ("pause");
- return 0;
- }
複製代碼 |