标签:can lse close 现在 opened alt 相加 content return
3 8
0010000000100
0110000001100
0010000000100
0010000000100
0010000000100
0010000000100
0111000001110
1 #include<iostream> 2 #include<stdio.h> 3 #include<string.h> 4 #include<string> 5 #include<vector> 6 #include<algorithm> 7 #define ll long long 8 using namespace std; 9 #define N 100 10 11 char s1[100],s2[100]; 12 int sum[100]; 13 vector<int>order; 14 15 char num[12][10][10]={ 16 {"01110","10001","10011","10101","11001", 17 "10001","01110"}, 18 {"00100","01100","00100","00100","00100", 19 "00100","01110"}, 20 {"01110","10001","00001","00110","01000", 21 "10000","11111"}, 22 {"11111","00001","00010","00110","00001", 23 "10001","01110"}, 24 {"00010","00110","01010","10010","11111", 25 "00010","00010"}, 26 {"11111","10000","10000","11110","00001", 27 "00001","11110"}, 28 {"01111","10000","10000","11110","10001", 29 "10001","01110"}, 30 {"11111","00001","00010","00100","00100", 31 "00100","00100"}, 32 {"01110","10001","10001","01110","10001", 33 "10001","01110"}, 34 {"01110","10001","10001","01111","00001", 35 "00010","11100"}, 36 {"000","000","000","000","000", 37 "000","000"}}; 38 39 void paint( ) 40 { 41 for(int i=0;i<=6;i++){ 42 for(int j=0;j<(int)order.size();j++){ 43 int x=order[j]; 44 printf("%s",num[x][i]); 45 } 46 cout<<endl; 47 } 48 } 49 50 51 int add(char s1[100],char s2[100]){ 52 int len1=strlen(s1); 53 int len2=strlen(s2); 54 int i1=len1-1,i2=len2-1,i3=0; 55 while(i1>=0&&i2>=0){ 56 sum[i3]+=s1[i1]-‘0‘+s2[i2]-‘0‘; //记得这里是加等于! 57 if(sum[i3]>=10){ 58 sum[i3+1]+=sum[i3]/10; 59 sum[i3]%=10; 60 } 61 i3++,i1--,i2--; 62 } 63 while(i1>=0){ 64 sum[i3]+=s1[i1]-‘0‘; 65 if(sum[i3]>=10){ 66 sum[i3+1]+=sum[i3]/10; 67 sum[i3]%=10; 68 } 69 i3++,i1--; 70 } 71 while(i2>=0){ 72 sum[i3]+=s2[i2]-‘0‘; 73 if(sum[i3]>=10){ 74 sum[i3+1]+=sum[i3]/10; 75 sum[i3]%=10; 76 } 77 i3++,i2--; 78 } 79 while(sum[i3]>=10){ //最终的进位情况!! 80 sum[i3+1]+=sum[i3]/10; 81 sum[i3]%=10; 82 i3++; 83 } 84 85 if(sum[i3]>0) 86 return i3+1; 87 else 88 return i3; 89 } 90 91 int main() 92 { 93 while(scanf("%s%s",s1,s2)!=EOF){ 94 memset(sum,0,sizeof(sum)); 95 int len3=add(s1,s2); //计算大数相加 96 97 /* for(int i=0;i<len3;i++){ 98 printf("%d",sum[i]); 99 } 100 cout<<"*****"<<endl; 101 */ 102 order.clear(); //生成次序 103 for(int i=len3-1;i>=0;i--){ 104 order.push_back(sum[i]); 105 if(i!=0) 106 order.push_back(10); 107 } 108 paint(); 109 } 110 111 112 return 0; 113 }
201/7/31-zznuoj-问题 A: A + B 普拉斯【二维字符串+暴力模拟+考虑瑕疵的题意-0的特例】
标签:can lse close 现在 opened alt 相加 content return
原文地址:https://www.cnblogs.com/zhazhaacmer/p/9399424.html