Advertisement
nguyenhappy92

In ra tam giác cân ngược

Oct 13th, 2015
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. // in ra tam giac can nguoc
  2. // Khai bao cca ham thu vien
  3. #include <iostream.h>
  4.  
  5. void main()
  6. {
  7. int n;
  8. cout <<"Nhap kich thuoc tam giac: "; cin>>n;
  9. cout <<"\n\n";
  10.  
  11. int a=(2*n-1);
  12. int b=(a /2+1);
  13.  
  14. for (int i=1;i<=n;i++)
  15. {
  16. for (int j=1;j<=a;j++)
  17. {
  18. if (i==1) cout <<"*";
  19. else if ((j<i) || (j>a+1-i)) cout <<" ";
  20. else cout <<"*";
  21. }
  22. cout <<"\n";
  23. }
  24.  
  25. cout <<"\n\n";
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement