jeudi 2 février 2017

multi-nested for loop C++ not finishing

I currently have a small assignment for my c++ college course. I'm currently running into an error where it runs the first two loops but then freezes and does not finishes the rest of the loops. the whole point is to printout a * diamond

an example would look like this if you entered the number 7:

     *
    ***
   *****
  *******
   *****
    ***
     * 

this is what the code looks like currently:

#include <iostream>
using namespace std;



int main(){
cout<<"How many lines do you want?";
int num_rows;
cin>>num_rows;
int row_average = (num_rows/2)+1;
for(int count=0; count<num_rows; ++count){
    int midpoint = row_average - count;
    int absolute = abs(midpoint);
    int spaces = absolute;


    for (int count_a = 0; count_a<spaces; ++count_a){
        cout<<" ";
    }
    for (int count_b = row_average; count_b<num_rows; ++count){
        int stars = count_b - spaces;
        for(int count_c = 0; count_c = stars; ++count_c){
            cout<<"*";
        }
    }
    }
}

Any answers or help would be appreciated! Thanks!

Aucun commentaire:

Enregistrer un commentaire