tesselation meaning code example

Example: tesselation

#include<iostream>
int main(){
  std::cout<<"Please enter the number of rows:\t";
  int rows;
  std::cin>>rows;
  std::cout<<"Please enter the number of columns:\t";  
  int columns;                                                   
  std::cin>>columns;
  unsigned int n=3;
  unsigned int k=4;
  unsigned int n_reserve{0};               
  unsigned int k_reserve{0};
  unsigned int which_row=1;
  if(columns>1){
      n=(columns)*6-n;
      k=((columns)*6)-(k)+2;
      n_reserve=n;
      k_reserve=k;
  }                                         
    for(int odd{1};odd<=(rows*3);++odd){    
        for(int j{columns*6};j>=1;--j){
          if(j==n){
              std::cout<<"\\"; // ==>  "/"
              if(n>3&&columns>1){n-=6;}
          }else if(j==k){
              std::cout<<"/";//  ==> "\"
              if(k>4&&columns>1){k-=6;}
          }else if(odd%3==0){
              std::cout<<'_';
          }else{
              std::cout<<" ";
          }
        }std::cout<<std::endl;
        if(columns>1){
          n=--n_reserve;
          k=++k_reserve;
          ++n;--k;
        }
          --n;
          ++k;
      if(odd%3==0){++which_row;}
      if(which_row%2==0&&odd%3==0)
      {// 29421  796842 */ ;)
        n_reserve=(columns)*6;
        k_reserve=((columns)*6)-5;
        n=n_reserve;
        k=k_reserve;
      }
      
    }
    return 0;
}

Tags:

Cpp Example