UVA 10878 Decode the tape

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.