Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- /* int n=7,a[n]={1,2,3,4,3,2,1};
- int c=1;
- for(int i=0;i<n/2;i++){
- if (a[i]==a[n-i-1]){
- c=1;
- }
- else{
- c=0;
- }
- }
- if(c==1){
- cout<<"good";
- }
- else{
- cout<<"bad";
- }
- */
- int n;
- int ch1=0,ch2=0;
- cout<<"1\n";
- cin>>n;
- cout<<"2"<<endl;
- int a[n];
- for(int b=0;b<n;b++){
- a[b]=0;
- }
- if(n%2==0){
- for (int i=0;i<n/2;i++){
- ch1+=1;
- a[i]=ch1;
- a[n-i-1]=a[i];
- cout<<a[i]<<" "<<a[n-i-1]<<endl;
- }
- }
- if (n%2==1){
- for (int j=0;j<n/2+1;j++){
- ch2+=1;
- a[j]=ch2;
- a[n-j-1]=a[j];
- }
- }
- for (int i=0;i<n;i++){
- cout<<a[i];
- }
- }
Add Comment
Please, Sign In to add comment