栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 3982 序列

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 3982 序列

#include <stdio.h>#include <string.h>#include <stdlib.h>void add(char a[],char b[],char back[]){    int i,j,k,up,x,y,z,l;    char *c;    if(strlen(a) > strlen(b))        l = strlen(a)+2;    else        l = strlen(b)+2;    c = (char*)malloc(l*sizeof(char));    i = strlen(a)-1;    j = strlen(b)-1;    k = 0;    up = 0;    while(j>=0 || i>=0)    {        if(i<0) x = '0';        else x = a[i];        if(j<0) y = '0';        else y = b[j];        z = x-'0'+y-'0';        if(up) z++;        if(z>9)        { up = 1; z%=10;        }        else up = 0;        c[k++] = z+'0';        i--;        j--;    }    if(up)        c[k++] = '1';    i = 0;    c[k] = '';    for(k-=1; k>=0; k--)        back[i++] = c[k];    back[i] = '';}int main(){    char a[1000],b[1000],c[1000],sum[1000];    int m,i;    while(~scanf("%s%s%s",a,b,c))    {        add(a,b,sum);        add(c,sum,sum);        int n = 5;        for(i = 1; i<=24; i++)        { add(b,c,a); add(sum,a,a); add(c,sum,b); add(b,a,b); add(sum,a,c); add(b,c,c); add(a,b,sum); add(c,sum,sum);        }        printf("%sn",sum);    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/378512.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号