Finally on the UVA see a short topic, happy. After reading the topic, I was ignorant. Then you find the rules ...
Find each line represents a letter, and then I start from a a control, write him out. Then a certain pattern was found: the important positions of each line were made up of ' o ' and '-', and a few of them found exactly 7, and then they thought of the Andean Code. Sure enough, the first one represents 2^6, the second represents 2^5, and so on ... If it is ' O ' on behalf of 1*2^X, otherwise it is 0, the added value is the Alpha code of the letter.
The first two times actually all re ...
#include <stdio.h> #include <string.h> #include <math.h>char tape[10000][150],end[]={"___________" };char Words[10000];int Main () {int I=0,j=0,k,flag=0,t=0;char c;double sum=0; while (1) {//printf ("%d\n", I); while ((C=getchar ())! = ' \ n ') tape[i][j++]=c; tape[i][11]= ' + '; if (flag&&strcmp (tape[i],end) ==0) break; flag=1; i++; j=0; } For (j=1;j<i;j++) { sum=0; for (k=2;k<=9;k++) { if (k>=2&&k<=5) { if (tape[j][k]== ' O ') Sum=sum+pow (2,8-k ); } if (k==6) continue; if (k>6&&k<=9) { if (tape[j][k]== ' o ') Sum=sum+pow (2,9-k); } } Words[j-1]=int (sum); } printf ("%s", words);}
After finished to see other people's blog, found that others just a few lines on the solution = = He opened the number of groups to save 2 x times, do not use the POW function.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
UVA 10878 Decode the tape