Have fun with numbers

Posted sunnybowen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Have fun with numbers相关的知识,希望对你有一定的参考价值。

#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
#include<string.h>
int main(int argc,char const *argv[]){
    char start[21];
    char end[21];
    int  flag1=1;
    gets(start);
    int t,i,j,s;
    t=strlen(start);
    int m=0;
    if((start[0]-0)*2>=10){
        end[0]=1;
        flag1=0;
    }
    for(i=t-1;i>=0;i--){
         if((start[i]-0)*2>=10){
             s=(start[i]-48)*2%10+m;
             end[i+1]=s+0;
             m=1;
         }else{
             s=(start[i]-48)*2+m;
             end[i+1]=s+0;
             m=0;
        }
    }
     int flag=1;

     for( i=1;i<=t;i++){
        for(j=0;j<t;j++){
            if(end[i]==start[j]){
                start[j]=a;
                break;
            }
        }
     }

     for(i=0;i<t;i++){
        if(start[i]!=a){
            flag=0;
            break;
        }
     }
     if(flag==1){
        printf("Yes
");
     }else{
        printf("No
");
     }

     if(flag1==0){
        for( i=0;i<=t;i++){
          printf("%c",end[i]);
        }
    }else{
        for(i=1;i<=t;i++){
            printf("%c",end[i]);
        }
    }
    /*
    for(int i=0;i<t;i++){
        printf("%c ", start[i]);
    }
    */
    return 0;
}

 题目列表: https://pintia.cn/problem-sets/994805342720868352/problems/994805478658260992

以上是关于Have fun with numbers的主要内容,如果未能解决你的问题,请参考以下文章

1023 Have Fun with Numbers

1023 Have Fun with Numbers

PAT1023. Have Fun with Numbers (20)

PAT 1023 Have Fun with Numbers

Have fun with numbers

PAT 甲级 1023 Have Fun with Numbers