2018年1月18日 星期四

UVA Q10878 - Decode the tape

#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main() {
    char a[11],d;
    int b,c;
    gets(a);
    while (gets(a)) {
        c=7;
        b=0;
        if (a[0] == '|') {
            for(int x=1;x<=9;x++){
                if(a[x]!='.'){
                    if(a[x]=='o'){
                        b=b+pow(2,c);
                    }
                    c--;   
                }   
            }
        d=b;
        cout<<d;
        }else if(a[0]=='_'){
            break;
        }
    }


    system("pause");
    return 0;
}

沒有留言:

張貼留言