- #include<bits/stdc++.h>
- #include<string.h>
- #include<list>
- #include<iterator>
- using namespace std;
- char rr[102];
- int main()
- {
- list<int>lst;
- int mx=0;
- list<int>:: iterator it;
- char str[102][102];
- int ii=0;
- while(cin>>str[ii] ){
- if(strlen(str[ii])==1 && str[ii][0]=='0'){
- break;
- }
- int stln=strlen(str[ii]);
- mx=max(mx,stln);
- ii++;
- }
- for(int i=0;i<ii;i++){
- int p=0;
- if(mx>strlen(str[i])){
- for(int j=strlen(str[i])-1;j>=0 ;j-- ){
- rr[p++]=str[i][j];
- }
- int ln=strlen(str[i]);
- while(ln<mx){
- rr[ln++]='0';
- }
- for(int l=0;l<mx;l++){
- str[i][l]=rr[mx-1-l];
- }
- for(int k=0;k<102;k++) rr[k]='0';
- }
- }
- int sum,r=0;
- for(int j=mx-1;j>=0;j--){
- sum=r;
- for(int i=ii-1;i>=0;i--){
- sum+= str[i][j]-'0';
- }
- lst.push_front(sum%10);
- r=sum/10;
- }
- if(r>0) lst.push_front(r);
- for(it=lst.begin();it!=lst.end();it++){
- cout<<*it;
- }
- puts("");
- lst.clear();
- return 0;
- }
Sunday, 30 September 2018
uva 424 Integer Inquiry solution
Subscribe to:
Comments (Atom)
variable declaration of c program
#include <stdbool.h> #include<bits/stdc++.h> #include <stdio.h> #include <string.h> #include <std...
-
#include<bits/stdc++.h> #include<cmath> #include<algorithm> #define mx 20000005 using namespace std ; ...
-
#include<stdio.h> #include<string.h> int main ( void ) { char y [ 100001 ] ; int m4,m100,m400,m15...
-
#include<bits/stdc++.h> using namespace std ; int main ( ) { int arr [ 10005 ] ; int n,m,mi,d ; ...