Decode the tape

时间:2022-05-08
本文章向大家介绍Decode the tape,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

输出结束是EOF,这个害我wa,水题,二进制转换为ascii

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int i,j;
    int ans=0,tes;
    char str[100];
    while(gets(str)!=NULL)
    {
        if(!strcmp(str,"___________")) continue;
        tes=0;
        for (i=0;str[i];i++)
        {
            if(str[i]=='o')
            {
                if(i<6) tes+=pow(2,8-i);
                else tes+=pow(2,9-i);
            }
        }
        printf("%c",tes);
    }
    return 0;
}