Advertisement
camilosasuketbs

Untitled

Oct 4th, 2022
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | Software | 0 0
  1.  
  2. int twitch::octaelliptical_star_main_only_odd_count_main()
  3. {
  4.    printf("Star Line Count (Odd Line number output only and negative for exiting...)");
  5.    //int n;
  6.    //cin >> n;
  7.    //if (n < 0)
  8.    //{
  9.  
  10.    //   return n;
  11.  
  12.    //}
  13.    //n /=2;
  14.    //int a = 1;
  15.    //while (a <= n) {
  16.    //   int k = 1;
  17.    //   while (k <= n - a) {
  18.    //      cout << " ";
  19.    //      k++;
  20.    //   }
  21.  
  22.    //   int j = 1;
  23.    //   while (j <= 2 * a - 1) {
  24.    //      cout << "*";
  25.    //      j++;
  26.    //   }
  27.  
  28.    //   cout << endl;
  29.    //   a++;
  30.    //}
  31.  
  32.  
  33.    //int i = n - 1;
  34.    //while (i >= 1) {
  35.    //   int p = 1;
  36.    //   while (p <= n - i) {
  37.    //      cout << " ";
  38.    //      p++;
  39.    //   }
  40.    //   int c = 1;
  41.    //   while (c <= 2 * i - 1) {
  42.    //      cout << "*";
  43.    //      c++;
  44.    //   }
  45.  
  46.  
  47.    //   cout << endl;
  48.    //   i--;
  49.  
  50.    //}
  51.  
  52.  
  53.  
  54.    int n;
  55.    cin >> n;
  56.    bool bEven = (n % 2) == 0;
  57.    if (bEven)
  58.    {
  59.  
  60.       cout << "(No output for even line count)\n";
  61.       return 0;
  62.    }
  63.    bool bOdd = !bEven;
  64.    n /= 2;
  65.    if (bOdd)
  66.    {
  67.       n++;
  68.    }
  69.    int a = 1;
  70.    //if (extraline)
  71.    //{
  72.    //   a--;
  73.  
  74.    //}
  75.    while (a <= n) {
  76.       int k = 1;
  77.       while (k <= n - a) {
  78.          cout << " ";
  79.          k++;
  80.       }
  81.  
  82.       int j = 1;
  83.       while (j <= 2 * a - 1) {
  84.          cout << "*";
  85.          j++;
  86.       }
  87.  
  88.       cout << endl;
  89.       a++;
  90.    }
  91.  
  92.  
  93.  
  94.    int i = n - 1;
  95.    while (i >= 1) {
  96.       int p = 1;
  97.       while (p <= n - i) {
  98.          cout << " ";
  99.          p++;
  100.       }
  101.       int c = 1;
  102.       while (c <= 2 * i - 1) {
  103.          cout << "*";
  104.          c++;
  105.       }
  106.  
  107.  
  108.       cout << endl;
  109.       i--;
  110.  
  111.    }
  112.  
  113.    return 0;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement