Advertisement
fiqriachmada

RenaldiDeretanBarisUsingFor

Nov 28th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <math.h>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     double x,y;
  11.     int n;
  12.     cout<<"X = ";
  13.     cin>>x;
  14.     cout<<"Y = ";
  15.     cin>>y;
  16.     cout<<"N = ";
  17.     cin>>n;
  18.  
  19.     int limit = ceil((y-x) / n);
  20.     int d= (limit* n) +x-1;
  21.  
  22.     long a = 1;
  23.  
  24.     int b = 1;
  25.  
  26.     int c = 0;
  27.     for(int i=1;i<=d;i++){
  28.         a=a*n%10;
  29.  
  30.     if (i>=x){
  31.         if (b==limit){
  32.             b=0;
  33.             if(a==0&&c==0){
  34.                 cout<<setw(3)<<endl;
  35.                 c++;
  36.             }
  37.             else if(a==0&&c!=0){
  38.                 cout<<setw(3)<<endl;
  39.                 c==2?c=0:c++;
  40.             }
  41.             else if (i <= y){
  42.                 cout<<setw(3)<<a<<endl;
  43.             } else {
  44.                 c==0?cout<<setw(3)<<"x":cout<<setw(3)<<"x";
  45.                 c==2?c=0:c++;
  46.             }
  47.         } else {
  48.             if (a==0&&c==0){
  49.                 cout<<setw(3)<<" ";
  50.                 c++;
  51.             }
  52.             else if (a==0&&c!=0){
  53.                 cout<<setw(3)<<" ";
  54.                 c==2?c=0:c++;
  55.             }
  56.             else if (a==0&&c!=0){
  57.                 cout<<setw(3)<<" ";
  58.                 c==2?c=0:c++;
  59.             }
  60.             else if (i<=y){
  61.                 cout<<setw(3)<<a;
  62.             } else {
  63.                 c==0?cout<<setw(3)<<"x":cout<<setw(3)<<"x";
  64.                 c==2?c=0:c++;
  65.             }
  66.         }
  67.         b++;
  68.     }
  69.  
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement