• 杭电oj 1002 wrong answer(待改正)


    /*#include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    int main(){


    int n;
    int i,j,q;//计数
    int al=0;
    int bl=0;
    int cl,dl;
    char turn;
    char a[1001];
    char b[1001];
    char c[1002];
    int sum[1002];
    for(i=0;i<1001;i++){
    sum[i]=a[i]=b[i]=c[i]='0';
    }
    scanf("%d",&n);
    for(i=1;i<=n;i++){
    scanf("%s %s",a,b);
    printf("Case %d: ",i);
    printf("%s + %s = ",a,b);

    al=strlen(a);
    bl=strlen(b);
    cl=al>bl?al:bl;
    for(j=0,q=al;j<q-1;j++,q--){
    turn=a[j];
    a[j]=a[q-1];
    a[q-1]=turn;
    }
    for(j=0,q=bl;j<q-1;j++,q--){
    turn=b[j];
    b[j]=b[q-1];
    b[q-1]=turn;
    }

    for(j=al;j<cl;j++){
    a[j]='0';
    }
    for(j=bl;j<cl;j++){
    b[j]='0';
    }
    for(j=0;j<cl;j++){
    if(a[j]+b[j]-'0'-'0'>9)
    c[j+1]='1';
    sum[j]=(a[j]+b[j]+c[j]-'0'-'0'-'0')%10;

    }


    if(c[cl]=='1')
    printf("1");

    for(j=cl-1;j>=0;j--){
    printf("%d",sum[j]);

    }
    if(i!=n)
    printf(" ");

    }


    }
    */

    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    int main(){


    int n;
    int i,j,q;//计数
    int al=0;
    int bl=0;
    int cl,dl;
    char turn;
    char a[1001];
    char b[1001];
    char c[1002];
    int sum[1002];
    for(i=0;i<1001;i++){
    sum[i]=a[i]=b[i]=c[i]='0';
    }
    scanf("%d",&n);
    for(i=1;i<=n;i++){
    scanf("%s %s",a,b);



    al=strlen(a);
    bl=strlen(b);
    cl=al>bl?al:bl;
    for(j=0,q=al;j<q-1;j++,q--){
    turn=a[j];
    a[j]=a[q-1];
    a[q-1]=turn;
    }
    for(j=0,q=bl;j<q-1;j++,q--){
    turn=b[j];
    b[j]=b[q-1];
    b[q-1]=turn;
    }

    for(j=al;j<cl;j++){
    a[j]='0';
    }
    for(j=bl;j<cl;j++){
    b[j]='0';
    }
    for(j=0;j<cl;j++){
    if(a[j]+b[j]-'0'-'0'>9)
    c[j+1]='1';
    sum[j]=(a[j]+b[j]+c[j]-'0'-'0'-'0')%10;

    }

    printf("Case %d: ",i);
    for(j=al-1;j>=0;j--)
    printf("%c",a[j]);
    printf(" + ");
    for(j=bl-1;j>=0;j--)
    printf("%c",b[j]);
    printf(" = ");
    if(c[cl]=='1')
    printf("1");

    for(j=cl-1;j>=0;j--){
    printf("%d",sum[j]);

    }
    if(i!=n)
    printf(" ");

    }

    system("pause");

    }

  • 相关阅读:
    beautifulsoup的一些使用
    requests(爬虫常用)库的使用
    find a maximum product triplet in this array
    Minimum difference between two arrays
    [LeetCode] Binary Tree Upside Down
    n 刀切多少块pizza
    Biased Random Number Generator
    linked list焦点问题,面经里很多,考虑相交不相交,有环无环 + Find Leaves of Binary Tree (Java)
    replace string use another
    Union and Intersection of two sorted list
  • 原文地址:https://www.cnblogs.com/ganeveryday/p/4375768.html
Copyright © 2020-2023  润新知