UVa 10878 - Decode the tape

#include<stdio.h>

#include<string.h>

int main()

{

    char str[15];

    int a;

    scanf("%s",str);getchar();

    while(1)

    {

        fgets(str,sizeof(str),stdin);

        if(str[0]=='_')

        {

            break;

        }

        a=0;

        if(str[9]=='o') a+=1;

        if(str[8]=='o') a+=2;

        if(str[7]=='o') a+=4;

        if(str[5]=='o') a+=8;

        if(str[4]=='o') a+=16;

        if(str[3]=='o') a+=32;

        if(str[2]=='o') a+=64;

        if(str[1]=='o') a+=128;

        printf("%c",a);



    }

    return 0;

}

 

你可能感兴趣的:(decode)