标题:acm杭电1002题求大神帮我看看
只看楼主
Husopp
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-3-4
结帖率:0
已结贴  问题点数:20 回复次数:1 
acm杭电1002题求大神帮我看看
#include <stdio.h>
#include<string.h>
int main()
{
    int n,j,k,s1,s2,leap=0,t,s,i;
     char a[1000],b[1000];
     int c[1001];
    char *p,*p1,*p2;
     while(scanf("%d",&n)!=EOF)
     {
         for(i=0;i<n;i++)
         {
             scanf("%s",a); scanf("%s",b);
             p1=a; p2=b;
             s1=strlen(a); s2=strlen(b);
             if(s1>1) p1=p1+s1;
             if(s2>1) p2=p2+s2;
             if(s1>s2) p=a;
             else p=b;
             k=s1;
             if(s1<s2) k=s2;
             for(j=0;j<k;j++)
             {
                 t=*p1-48+*p2-48;
                 if(leap==1){t++; leap=0;}
                 if(t>9){t=t%10; leap==1;}
                 c[j]=t;  p1--;  p2--;
                 printf("{%c+%c+%d+%d}",*p1,*p2,t,c[j]);
              }     
              s=j;
             printf("Case %d:\n",i+1);
             printf("%s + %s = ",a,b);
             while(leap==1)
             {
                 if(s1==s2)
                 { c[j]=1; leap=0;}
                 else
                 {
                     t=p[j]-47;
                     if(t>9) t=t%10;
                     else leap =0;
                     c[j]=t;
                     j++;
                 }
                 for(j=0;j<s1-k||j<s2-k;j++)
                 printf("%c",p[j]);
                 while(s>=0)
                 { printf("%d",c[s]); s--;}
            
             }
                printf("\n\n");
         }
     }
     return 0;
}c数组赋值进不去,也输出不出来
搜索更多相关主题的帖子: include 
2017-03-04 15:14
wp231957
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:神界
等 级:版主
威 望:422
帖 子:13681
专家分:53296
注 册:2012-10-18
得分:20 
题目也不贴一贴  谁知道你的代码都是干嘛的啊

DO IT YOURSELF !
2017-03-04 16:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-474739-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.077074 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved