Advertisement
nguyenhappy92

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

Oct 13th, 2015
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. // In ra tam giac can nguoc rong ruot
  2. // Khai bao chuong trinh nhu sau
  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)
  19. {
  20. if ((j%2)!=0) cout <<"*";
  21. else cout <<" ";
  22. }
  23. else if ((j==i) || (j==a+1-i)) cout <<"*";
  24. else cout <<" ";
  25.  
  26. }
  27. cout <<"\n";
  28. }
  29.  
  30. cout <<"\n\n";
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement