10878 - Decode the tape

#include <stdio.h>
#include <string.h>
int main()
{
	//freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
	char ch[1000];
	gets(ch);
	while(gets(ch)&&strcmp(ch,"___________"))
	{
		int len=strlen(ch);
		char num,j;
		num=0;
		j=1;
		for(int i=len-2;i>=1;i--)
		{
			if(ch[i]=='o')
			{
				num+=j;
				j*=2;
			}
			else if(ch[i]==' ')
			{
				j*=2;
			}
		}
		printf("%c",num);
	}
	return 0;
}


你可能感兴趣的:(10878 - Decode the tape)