Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #include<iostream>
  2.  
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8.  
  9. {
  10.  
  11. int i,j,k,n,ch;
  12.  
  13. do{
  14.  
  15. cout<<"\nMenu";
  16.  
  17. cout<<"\n1. Square pattern";
  18.  
  19. cout<<"\n2. Triangle pattern";
  20.  
  21. cout<<"\n3. Diaginal pattern";
  22.  
  23. cout<<"\n4. Reverse diaginal pattern";
  24.  
  25. cout<<"\n5. Quit";
  26.  
  27. cin>>ch;
  28.  
  29. switch(ch)
  30.  
  31. {
  32.  
  33. case 1: a1:
  34.  
  35. cout<<"\nEnter Size:";
  36.  
  37. cin>>n;
  38.  
  39. if(n>=1 && n<=9)
  40.  
  41. {
  42.  
  43. for(i=0;i<n;i++)
  44.  
  45. {
  46.  
  47. for(j=0;j<n;j++)
  48.  
  49. { cout<<n; }
  50.  
  51. cout<<"\n";
  52.  
  53. }
  54.  
  55. }
  56.  
  57. else
  58.  
  59. {
  60.  
  61. cout<<"\nYour Size is Out of range!!";
  62.  
  63. goto a1;}
  64.  
  65. break;
  66.  
  67. case 2:a2:
  68.  
  69. cout<<"\nEnter Size:";
  70.  
  71. cin>>n;
  72.  
  73. if(n>=1 && n<=9)
  74.  
  75. {
  76.  
  77. for(i=0;i<n;i++)
  78.  
  79. {
  80.  
  81. for(j=0;j<=i;j++)
  82.  
  83. { cout<<n; }
  84.  
  85. }
  86.  
  87. }
  88.  
  89. else
  90.  
  91. {
  92.  
  93. cout<<"\nYour Size is Out of range!!";
  94.  
  95. goto a2;}
  96.  
  97. break;
  98.  
  99. case 3:a3:
  100.  
  101. cout<<"\nEnter Size:";
  102.  
  103. cin>>n;
  104.  
  105. if(n>=1 && n<=9)
  106.  
  107. {
  108.  
  109. for(i=0;i<n;i++)
  110.  
  111. {
  112.  
  113. for(j=0;j<i;j++)
  114.  
  115. {
  116.  
  117. cout<<"*";
  118.  
  119. }
  120.  
  121. cout<<n;
  122.  
  123. for(j=i+1;j<n;j++)
  124.  
  125. {
  126.  
  127. cout<<"*";
  128.  
  129. }
  130.  
  131. cout<<"\n";
  132.  
  133. }
  134.  
  135. }
  136.  
  137. else
  138.  
  139. {
  140.  
  141. cout<<"\nYour Size is Out of range!!";
  142.  
  143. goto a3;}
  144.  
  145. break;
  146.  
  147. case 4:a4:
  148.  
  149. cout<<"\nEnter Size:";
  150.  
  151. cin>>n;
  152.  
  153. if(n>=1 && n<=9)
  154.  
  155. {
  156.  
  157. for(i=0;i<n;i++)
  158.  
  159. {
  160.  
  161. for(j=1;j<n-i;j++)
  162.  
  163. {
  164.  
  165. cout<<"*";
  166.  
  167. }
  168.  
  169. cout<<n;
  170.  
  171. for(j=0;j<i;j++)
  172.  
  173. {
  174.  
  175. cout<<"*";
  176.  
  177. }
  178.  
  179. cout<<"\n";
  180.  
  181. }
  182.  
  183. }
  184.  
  185. else
  186.  
  187. {
  188.  
  189. cout<<"\nYour Size is Out of range!!";
  190.  
  191. goto a4;}
  192.  
  193. break;
  194.  
  195. case 5:
  196.  
  197. return 0;
  198.  
  199. break;
  200.  
  201. default: return 0;
  202.  
  203. }
  204.  
  205. }while(ch>0 && ch< 5);
  206.  
  207.  
  208.  
  209. return 0;
  210.  
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement