Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include<iostream>
#include<string>
using namespace std;
int main(){
int n;
cin>>n;
string s;
int count = 0;
for(int i = 0; i < n; i++){
cin>>s;
if(s == "Tetrahedron"){
count += 4;
continue;
}
else if(s == "Cube"){
count += 6;
continue;
}
else if(s == "Octahedron"){
count += 8;
continue;
}
else if(s == "Dodecahedron"){
count += 12;
continue;
}
else{
count += 20;
continue;
}
}
cout<<count;
return 0;
}
Copy The Code &
Try With Live Editor
Input
4
Icosahedron
Cube
Tetrahedron
Dodecahedron
Icosahedron
Cube
Tetrahedron
Dodecahedron
Output
42
Demonstration
Codeforcess Solution 785-A A. Anton and Polyhedrons ,C++, Java, Js and Python ,785-A,Codeforcess Solution