10878 - Decode the tape

    技术2022-06-22  55

    Decode the tapeTime Limit: 1 second

     

    "Machines take me by surprise with great frequency." Alan Turing

    Your boss has just unearthed a roll of old computer tapes. The tapes have holes in them and might contain some sort of useful information. It falls to you to figure out what is written on them.

    InputThe input will contain one tape.

    OutputOutput the message that is written on the tape.

    Sample Input Sample Output ___________ | o . o| | o . | | ooo . o| | ooo .o o| | oo o. o| | oo . oo| | oo o. oo| | o . | | oo . o | | ooo . o | | oo o.ooo| | ooo .ooo| | oo o.oo | | o . | | oo .oo | | oo o.ooo| | oooo. | | o . | | oo o. o | | ooo .o o| | oo o.o o| | ooo . | | ooo . oo| | o . | | oo o.ooo| | ooo .oo | | oo .o o| | ooo . o | | o . | | ooo .o | | oo o. | | oo .o o| | o . | | oo o.o | | oo . o| | oooo. o | | oooo. o| | o . | | oo .o | | oo o.ooo| | oo .ooo| | o o.oo | | o. o | ___________ A quick brown fox jumps over the lazy dog.

     


    Problemsetter: Igor NavernioukSpecial thanks: BSD games ppt.

     #include <stdio.h> #include <math.h> int main() { char line[13]; int sum; int i; while(fgets(line, sizeof(line), stdin)!=NULL) { if (line[0] == '_'){ continue; } sum = 0; for (i = 1; i < 10; i++) { if (line[i] == 'o') { if (i==6) continue; else if (i>6) { sum += pow(2, 9 - i); } else { sum += pow(2, 8 - i); } } } printf("%c", sum); } return 0; }

     


    最新回复(0)