Advertisement
KAR98S

AlphabetBridge

Sep 16th, 2019 (edited)
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. /*
  4. int recj(int n, bool firstIt=true,int x=0,int nR=0,int N=0,int offset=0){
  5.     if(!n) return 0;
  6.     else{
  7.         if(firstIt){
  8.             nR = n+1;
  9.             N = nR/2;
  10.             return recj(n,false,x,nR,N,offset);
  11.         }
  12.         cout<<((offset<x)?(char)(65 + offset):' ')<<' ';
  13.         return recj(n-1,false,x,nR,N,offset + ((nR-n<N)?1:-1));
  14.        
  15.     }
  16. }
  17. int reci(int n,bool firstIt=true,int N=0){
  18.     if(!n) return 0;
  19.     else {
  20.         if(firstIt){
  21.             N=n;
  22.             return reci(n,false,N);
  23.         }
  24.         recj(2*N-1,true,n);
  25.         cout<<'\n';
  26.         return reci(n-1,false,N);
  27.     }
  28. }*/
  29. int main() {
  30.     int n,offset=0;
  31.     cin>>n;
  32.     for(int i=0,x=n;i<n;i++,offset=0,x--){
  33.         for(int j=0;j<2*n-1;j++,(offset+=(j<n)?1:-1)){
  34.             cout<<((offset<x)?(char)(65 + offset):' ')<<' ';
  35.         }
  36.         cout<<endl;
  37.     }
  38.     //reci(n);
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement