Frooster

X-Shape

May 17th, 2015
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.76 KB | None | 0 0
  1. /*
  2.  
  3. simple for loop program
  4.  
  5. working
  6. 1.for loop is used for increasing the mid width for the inverted v  structure and then decreased to get the  v structure
  7.  
  8. */
  9.  
  10.  
  11.  
  12. #include <iostream.h>
  13. #include <conio.h>
  14. #include <stdio.h>
  15.  //using namespace std;
  16.  
  17.  int main()
  18.  {
  19.      system("COLOR 4E");
  20.            int max =10;
  21.            int min=0;
  22.            int mid,left;
  23.            
  24.            for(int mid=max,left=min;mid>=0;left++,mid-=2)
  25.            {
  26.            
  27.             for(int k=0;k<=left;k++)
  28.            
  29.                     printf(" ");
  30.                     printf("*");
  31.                    
  32.                     for(int time=0;time<10000000;time++);
  33.                    
  34.            
  35.                            
  36.             for(int k=0;k<=mid;k++)
  37.                  
  38.                     printf(" ");
  39.                    
  40.                     printf("*");
  41.                    
  42.                      printf("\n");
  43.                      for(int time=0;time<100000000;time++);
  44.                        
  45.                      }
  46.                      
  47.              for(mid=max,left=max/2;left>=0;left--,mid+=2)
  48.              
  49.              {
  50.                            
  51.                       for(int k=0;k<=left;k++)
  52.            
  53.                     printf(" ");
  54.                     printf("*");
  55.                     for(int time=0;time<100000000;time++);
  56.                    
  57.            
  58.                            
  59.             for(int k=0;k<=mid-10;k++)
  60.                  
  61.                     printf(" ");
  62.                    
  63.                     printf("*");
  64.                    
  65.                      printf("\n");
  66.                      for(int time=0;time<100000000;time++);
  67.                        
  68.                      }
  69.                      
  70.                      
  71.                      for(mid=max,left=min;mid>=0;left++,mid-=2)
  72.                      {
  73.                       for(int k=0;k<=left;k++)
  74.                      
  75.                               cout<<" ";
  76.                               cout<<"*";
  77.                       for(int k=0;k<=mid;k++)
  78.                      
  79.                               cout<<" ";
  80.                              
  81.                               cout<<"*"<<"\n";
  82.                              
  83.                               }
  84.                                      
  85.                                            
  86.                                            
  87.                                            
  88.                                            
  89.                                            
  90.                                            
  91.                                            
  92.        getch();
  93.                                              
  94.                      
  95.       return 0;
  96.  
  97.       }
Advertisement
Add Comment
Please, Sign In to add comment