Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using std::cout;
  4. using std::cin;
  5. using std::endl;
  6.  
  7. void main()
  8. {
  9.  
  10. int size, k = 0;
  11.  
  12. cin >> size; cout << endl;
  13.  
  14. for (int i = 0; i < size; i++)
  15. {
  16. for (int j = 0; j <= k; j++)
  17. {
  18. if (k >= j) cout << "*";
  19. }
  20.  
  21. if (i < (size / 2)) k++; else k--;
  22. cout << endl;
  23. }
  24.  
  25. }
  26.  
  27. for (int i = 0; i < size; i++)
  28. {
  29. k = (size-1)/2 - abs((size-1-2*i)/2);
  30. for (int j = 0; j <= k; j++)
  31. {
  32. if (k >= j) cout << "*";
  33. }
  34. cout << endl;
  35. }
  36.  
  37. int size = 6;
  38. for (int i = 1; i <= size; i++)
  39. {
  40. int nstars = std::min(i, size + 1 - i);
  41. std::cout << std::string(nstars, '*') << std::endl;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement