Advertisement
askarulytarlan

задача 3

Oct 3rd, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4. #include <math.h>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int n;
  10. int c = 1;
  11.  
  12. int main(int argc, const char * argv[]) {
  13.  
  14. cin >> n;
  15. int b = n - 1;
  16. for (int i = 1 ; i <= n ; i++ ) {
  17. for(int j = 1 ; j <= b ; j++ ) {
  18. cout << " ";
  19. }
  20. for(int d = 1 ; d <= c ; d++ ) {
  21. cout << "*";
  22. }
  23. for(int j = 1 ; j < i ; j++ ) {
  24. cout << "*";
  25. }
  26. c = c + 1;
  27. b = b - 1;
  28. cout << endl;
  29. }
  30. int y = n-1;
  31. int g = 2;
  32. for (int i = n ; i >=1 ; i-- ) {
  33. for(int d = 1 ; d < g ; d++ ) {
  34. cout << " ";
  35. }
  36. for(int j = 1 ; j <= y ; j++ ) {
  37. cout << "*";
  38. }
  39. for(int j = 1 ; j < y ; j++ ) {
  40. cout << "*";
  41. }
  42. g = g + 1;
  43. y = y - 1;
  44. cout << endl;
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement