kilolilo

Untitled

Nov 10th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. /* int n=7,a[n]={1,2,3,4,3,2,1};
  8.  int c=1;
  9.  for(int i=0;i<n/2;i++){
  10.      if (a[i]==a[n-i-1]){
  11.          c=1;
  12.      }
  13.      else{
  14.          c=0;
  15.      }
  16.  }
  17.  if(c==1){
  18.      cout<<"good";
  19.  }
  20.  else{
  21.      cout<<"bad";
  22.  }
  23. */
  24.  int n;
  25.  int ch1=0,ch2=0;
  26.  cout<<"1\n";
  27.  cin>>n;
  28.  cout<<"2"<<endl;
  29.  int a[n];
  30.  for(int b=0;b<n;b++){
  31.      a[b]=0;
  32.  }
  33.  if(n%2==0){
  34.      for (int i=0;i<n/2;i++){
  35.          ch1+=1;
  36.          a[i]=ch1;
  37.  
  38.          a[n-i-1]=a[i];
  39.          cout<<a[i]<<"   "<<a[n-i-1]<<endl;
  40.      }
  41.  }
  42.  if (n%2==1){
  43.      for (int j=0;j<n/2+1;j++){
  44.          ch2+=1;
  45.          a[j]=ch2;
  46.          a[n-j-1]=a[j];
  47.      }
  48.  }
  49.  for (int i=0;i<n;i++){
  50.      cout<<a[i];
  51.  }
  52.  
  53. }
Add Comment
Please, Sign In to add comment