Created
June 22, 2017 09:23
-
-
Save dicenull/b6f689e068365f6cec671bb2bb907690 to your computer and use it in GitHub Desktop.
pck練習
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
// それぞれの入力を入れる配列 | |
int t[4]; | |
int n[4]; | |
// 入力を4回受け取る | |
for (int i = 0; i < 4; i++) | |
{ | |
cin >> t[i] >> n[i]; | |
} | |
// 4回ループ | |
for (int i = 0; i < 4; i++) | |
{ | |
if (t[i] == 1) // S席の場合 | |
{ | |
cout << 6000 * n[i] << endl; | |
} | |
else if (t[i] == 2) // A席の場合 | |
{ | |
cout << 4000 * n[i] << endl; | |
} | |
else if (t[i] == 3) // B席の場合 | |
{ | |
cout << 3000 * n[i] << endl; | |
} | |
else if(t[i] == 4) // C席の場合 | |
{ | |
cout << 2000 * n[i] << endl; | |
} | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
// それぞれの答え用変数 | |
int ans[4]; | |
// それぞれの席の値段 | |
int prices[] = { 6000, 4000, 3000, 2000 }; | |
// 入力を受け取る変数 | |
int t, n; | |
// 4回ループ | |
for (int i = 0; i < 4; i++) | |
{ | |
// 入力 | |
cin >> t >> n; | |
// 配列は0から始まるので1引く | |
t--; | |
// 答えを入れる | |
ans[i] = prices[t] * n; | |
} | |
// それぞれの答えを出力 | |
for (int i = 0; i < 4; i++) | |
{ | |
cout << ans[i] << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment