Advertisement
Jordimario

pezzo programma cimino

Mar 15th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. int base=0, numten, inv[100],num1[100], num2[100],somma[100],i=0,len,lenTot,conversione=0;
  2. bool riporto=0;
  3.  
  4. do{  
  5. i=lenTot;
  6.  while(i>=0){
  7.             somma[i] = (somma[i]+num1[i]+riporto<base) ? (num1[i]+somma[i]+riporto) : (num1[i]+somma[i]+riporto)%base;
  8.             riporto =  num1[i]+somma[i]+riporto>=base;
  9.             i--;
  10.     }
  11.         somma[i-1]=riporto;
  12.  
  13.     i = riporto ? -1 : 0;
  14.     cout<<"la somma dei numeri e'"<<endl;
  15.     while(i<lenTot){
  16.         cout<<somma[i];
  17.         conversione+=num1[i]*pow(base,len-i-1);
  18.         i++;
  19.     }}while(num1[-1]>0)
  20. cout<<"programma finito"<<endl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement