adiboier

Inmultire nr mari

Feb 6th, 2016
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4. ifstream fin("date.in");
  5. ofstream fout("date.out");
  6. int a[1000];
  7. int main()
  8. {
  9.     char c;
  10.     while(fin>>c)
  11.     {
  12.         if(c>='0' && c<='9')
  13.         {
  14.             a[0]++;
  15.             a[a[0]]=c-48;
  16.         }
  17.         else break;
  18.     }
  19.     int k;
  20.     fin>>k;
  21.     int transport=0;
  22.     for(int i=a[0];i>=1;i--)
  23.     {
  24.         if(transport==0)
  25.         {
  26.             transport=(a[i]*k-(a[i]*k)%10)/10;
  27.             a[i]=(a[i]*k)%10;
  28.         }
  29.         else
  30.         {
  31.             a[i]=(a[i]*k)%10+transport;
  32.             transport=(a[i]-a[i]%10)/10;
  33.         }
  34.     }
  35.     for(int i=1;i<=a[0];i++)
  36.         fout<<a[i];
  37.     fin.close();
  38.     fout.close();
  39.     return 0;
  40. }
Add Comment
Please, Sign In to add comment