-
Notifications
You must be signed in to change notification settings - Fork 0
/
Id and Ship
60 lines (53 loc) · 1.17 KB
/
Id and Ship
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Problem
Write a program that takes in a letterclass ID of a ship and display the equivalent string class description of the given ID. Use the table below.
Class ID Ship Class
B or b BattleShip
C or c Cruiser
D or d Destroyer
F or f Frigate
Input
The first line contains an integer T, the total number of testcases. Then T lines follow, each line contains a character.
Output
For each test case, display the Ship Class depending on ID, in a new line.
Constraints
1 ≤ T ≤ 1000
Example
Input
3
B
c
D
Output
BattleShip
Cruiser
Destroyer
answer:
#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace::std;
int main(int argc, const char * argv[]) {
int t;
cin >> t;
while (t--) {
char n;
cin >> n;
n = toupper(n);
switch (n) {
case 'B':
cout << "BattleShip" << endl;
break;
case 'C':
cout << "Cruiser" << endl;
break;
case 'D':
cout << "Destroyer" << endl;
break;
default:
cout << "Frigate" << endl;
break;
}
}
return 0;
}