-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_1.cpp
More file actions
36 lines (25 loc) · 807 Bytes
/
string_1.cpp
File metadata and controls
36 lines (25 loc) · 807 Bytes
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
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
cin.ignore(); // Ignore the newline character left in the buffer
string shapes[5]= {"Tetrahedron", "Cube", "Octahedron", "Dodecahedron", "Icosahedron"};
string *str = new string[n]; // Allocate memory dynamically using new
int faces[5]= {4, 6, 8, 12, 20};
for(int i=0; i<n; i++){
getline(cin, str[i]);
}
int total_faces = 0;
for(int j=0; j<n; j++){
for(int k=0; k<5; k++){
if(str[j] == shapes[k]){
total_faces+= faces[k];
}
}
}
cout << total_faces;
delete[] str; // Free the dynamically allocated memory
return 0;
}