#include <iostream>
#include <cmath>
using namespace std;
int getInt(char);
int main(){
long int sum[100] = {0};
int u = 0;
char a[100] = "";
cout << "WACMIAN Number: "; cin >> a;
while (a[0]!='#' || a[1] != '\0'){
if (a[0] != '#' || a[1] != '\0'){
for (int j = 0; a[j]!= '\0'; j++);
j--;
for (int i = j, base = 0; i >= 0; i--, base++){
sum[u] += getInt(a[i])*pow(6,base);
}
if (a[0] != '#')
u++;
}
cout << "WACMIAN Number: "; cin >> a;
}
cout << endl << "OUTPUT:\n";
for (int i =0; i <= u; i++){
if (a[0] == '#' && sum[i] == 0 && i==u)
break;
cout << sum[i] << endl;
}
return 0;
}
int getInt(char u){
switch (u){
case '%':
return 0;
case ')':
return 1;
case '~':
return 2;
case '@':
return 3;
case '?':
return 4;
case '\\':
return 5;
case '$':
return -1;
default:
cout << "Wrong input." << endl;
exit(0);
}
}
No comments:
Post a Comment