Anik_Akash

2757 - Input and Output of Integers

Oct 7th, 2020
94
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //thanks God For Every Thing!
  2. //contest link:
  3.  
  4. //#include<bits/stdc++.h>
  5. #include<iostream>
  6. #include<string>
  7. #include<algorithm>
  8. #include<cstdio>
  9. #define pi           acose(-1)
  10. #define flush        cin.ignore(numeric_limits<streamsize>::max(),'\n');
  11. #define wow          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  12. #define NL           printf("\n")
  13.  
  14. using namespace std;
  15.  
  16. typedef long long int           ll;
  17. typedef double                  dl;
  18.  
  19. // ---------------------- slove---------------------------//
  20.  
  21. int int_ln(int x);
  22.  
  23. int main()
  24. {
  25.     int a, b, c;
  26.     cin>>a>>b>>c;
  27.     cout<<"A = "<<a<<", B = "<<b<<", C = "<<c<<endl;
  28.  
  29.     int ln1, ln2, ln3;
  30.  
  31.     ln1 = int_ln(a);
  32.     ln2 = int_ln(b);
  33.     ln3 = int_ln(c);
  34. //----------------space print-----------//
  35.     cout<<"A = ";
  36.     for(int i=1; i<=10-ln1; i++)
  37.     {
  38.         cout<<" ";
  39.     }
  40.     cout<<a<<",";
  41.  
  42.     cout<<" B = ";
  43.     for(int i=1; i<=10-ln2; i++)
  44.     {
  45.         cout<<" ";
  46.     }
  47.     cout<<b<<",";
  48.  
  49.     cout<<" C = ";
  50.     for(int i=1; i<=10-ln3; i++)
  51.     {
  52.         cout<<" ";
  53.     }
  54.     cout<<c;
  55.     NL;
  56. //-----------------zero print---------------//
  57.     cout<<"A = ";
  58.     for(int i=1; i<=10-ln1; i++)
  59.     {
  60.         cout<<"0";
  61.     }
  62.     cout<<a<<",";
  63.  
  64.     cout<<" B = ";
  65.     for(int i=1; i<=10-ln2; i++)
  66.     {
  67.         cout<<"0";
  68.     }
  69.     cout<<b<<",";
  70.  
  71.     cout<<" C = ";
  72.     for(int i=1; i<=10-ln3; i++)
  73.     {
  74.         cout<<"0";
  75.     }
  76.     cout<<c;
  77.     NL;
  78. //---------------last pace---------//
  79. cout<<"A = "<<a;
  80.     for(int i=1; i<=10-ln1; i++)
  81.     {
  82.         cout<<" ";
  83.     }
  84.     cout<<",";
  85.  
  86.     cout<<" B = "<<b;
  87.     for(int i=1; i<=10-ln2; i++)
  88.     {
  89.         cout<<" ";
  90.     }
  91.     cout<<",";
  92.  
  93.     cout<<" C = "<<c;
  94.     for(int i=1; i<=10-ln3; i++)
  95.     {
  96.         cout<<" ";
  97.     }
  98.  
  99.     NL;
  100.  
  101.     return 0;
  102. }
  103. int int_ln(int x)
  104. {
  105.     int cnt=0, num;
  106.     while(x!=0)
  107.     {
  108.         cnt++;
  109.         num=x%10;
  110.         x/=10;
  111.     }
  112.  
  113.     return cnt;
  114. }
  115.  
RAW Paste Data