# 題目示範的範本 # Zerojude 題目範例 ### a005: Eva 的回家作業 https://zerojudge.tw/ShowProblem?problemid=a005 > ## 題目: > #### ############題目內文################### > ## 輸入說明: > #### ############輸入說明################### > ## 輸出說明: > #### ############輸入說明################### > ## 想法: > #### 對於等差與等比數列$a_{i}$與$a_{i+1}$的公差or公比皆相等,故可以用if做簡易的判斷。 > ## C++程式碼 ```c= #include <iostream> using namespace std; int main(){ int n; cin >> n; while(n--){ int a,b,c,d; cin >> a >> b >> c >> d; if(d/c==c/b&&c/b==b/a) cout << a << " " << b << " " << c << " " << d << " " << d*d/c; else cout << a << " " << b << " " << c << " " << d << " " << d+(d-c); /* d/c == c/b && c/b == b/a ? cout << a << " " << b << " " << c << " " << d << " " << d*d/c : cout << a << " " << b << " " << c << " " << d << " " << d+(d-c); */ cout << '\n'; } return 0; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up