zoukankan      html  css  js  c++  java
  • joj 1171

    水题,做1089太郁闷了所以刷了到水题,代码很笨,基本没有参考价值,只为看一眼快把我折磨死的气球。。。。。。。。。。。

    #include<iostream>
    #include<stdio.h>
    using namespace std;
    char str1[1005],str2[1005];
    int main()
    {
        while(scanf("%s%s",str1,str2)!=EOF)
        {
             int len1,len2,i=0;
             while(str1[i]!='\0')
                 i++;
             len1=i;
             i=0;
             while(str2[i]!='\0')
                 i++;
             len2=i;
             if(len1==len2)
             {
                 int i=len1-1;
                 int c=0;
                 while(i>=0)
                 {
                    
                     int m=c+str2[i]-'0'+str1[i]-'0';
                     str2[i]=m%10+'0';
                     c=m/10;
                     i--;
                 }
                 if(c!=0)
                    printf("%d%s\n",c,str2);
                 else
                    printf("%s\n",str2);
             }
             else if(len1<len2)
             {
                 int i=len1-1;
                 int c=0;
                 int q=len2-len1;
                 while(i>=0)
                 {
                    
                     int m=c+str2[i+q]-'0'+str1[i]-'0';
                     str2[i+q]=m%10+'0';
                     c=m/10;
                     i--;
                 }
                 q--;
                 while(c&&q>=0)
                 {
                     int m=c+str2[q]-'0';
                     str2[q]=m%10+'0';
                     c=m/10;
                     q--;
                 }
                 if(c)
                     printf("%d%s\n",c,str2);
                 else
                     printf("%s\n",str2);
             }
             else if(len1>len2)
             {
                 int i=len2-1;
                 int c=0;
                 int q=len1-len2;
                 while(i>=0)
                 {
                    
                     int m=c+str1[i+q]-'0'+str2[i]-'0';
                     str1[i+q]=m%10+'0';
                     c=m/10;
                     i--;
                 }
                 q--;
                 while(c&&q>=0)
                 {
                     int m=c+str1[q]-'0';
                     str1[q]=m%10+'0';
                     c=m/10;
                     q--;
                 }
                 if(c)
                     printf("%d%s\n",c,str1);
                 else
                     printf("%s\n",str1);
             }
        }
    }

  • 相关阅读:
    UML图箭头关系
    使用 Python 编写 vim 插件
    linux grep命令
    gevent For the Working Python Developer
    坐标系旋转变换公式图解
    欲哭无泪的p-value = 0.051 | 做几次重复能得到较低的p-value
    RNA-seq要做几次生物学重复?找出来的100%都是真正的应答基因
    Strand Specific mRNA sequencing 之重要性与分析
    为什么二代测序的原始数据中会出现Read重复现象?
    DNA甲基化研究概述
  • 原文地址:https://www.cnblogs.com/dchipnau/p/4985941.html
Copyright © 2011-2022 走看看