现在的位置: 首页 > 综合 > 正文

10878 – Decode the tape

2013年02月16日 ⁄ 综合 ⁄ 共 522字 ⁄ 字号 评论关闭

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1819

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
/*
o 代表1
空格 代表 0
. 忽略

由这些组成一个asc码 然后打印 
*/
int asc[] = {0,0,64,32,16,8,0,4,2,1};
int main()
{
	/*freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);*/
	char temp[12];
	int i;
	while(fgets(temp,12,stdin))
	{
		int sum=0;
		int len = strlen(temp);
		for(i=0; i<len; i++)
		{
			if(temp[i]=='|' || temp[i]=='.')
				continue;
			else if(temp[i]=='o')
			{
				sum+=asc[i];
			}			
		}
		if(sum!=0)
			printf("%c",sum);
	}
	return 0;
}















抱歉!评论已关闭.