loops

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int x, y, tempL, tempR, middle;
cout << "Please enter # of diamonds: ";
cin >> y;
while (y){
cout << "Please enter the size: ";
cin >> x;
if (x % 2 == 0) { middle = tempL=tempR = x / 2 ; }
else { middle=tempL= tempR = x / 2 + 1 ; }
for (int i=1; i<= x; i++){
for (int j=1; j<=x; j++){
if (j >= tempL && j<=tempR)
cout <<" *";
else
cout <<" ";

}
cout << endl;
if (i<middle){ tempL--; tempR++; }
else {tempL++; tempR--; }
}
y--;
}
return 0;
}
//change this to display to
//cpp.sh/4ir3
This post does not belong here. And this is your second time posting this. Please Do not post more than once.

Your Question Will continue here - http://www.cplusplus.com/forum/beginner/160292/
i Apologize i am new here i don't know where to post
beginner: people new to programming and or c++
windows: windows specific c++ programming
unix: linux/unix specific c/c++ programming with typical linux/unix apis including POSIX
general: intermediate questions (for example: implementing an algorithm) for c++
lounge: all the rest
jobs: job posting
Topic archived. No new replies allowed.