![]() |
|
c++ shapes - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: C, C++, & Obj-C (https://sinister.ly/Forum-C-C-Obj-C) +--- Thread: c++ shapes (/Thread-c-shapes) |
c++ shapes - millionandbell - 02-14-2017 can someone explain to me how to use two nested while loops to create shapes? i just don't understand how they work really, i have a project due next week that involves making a trapezoid via user input and then after that it uses the same input to factor every number up to the user input number i can post RE: c++ shapes - m0dem - 02-14-2017 What do you mean by "shapes"? ASCII? graphical? More information needed. RE: c++ shapes - millionandbell - 02-15-2017 Code: #include <iostream>
using namespace std;
int main()
{
unsigned size;
bool solid = true; //solid or hollow shape?
cout <<"Size: ? ";
cin >>size;
size = 5;
cout << endl;
for ( unsigned r = 0; r < size; r++ ){ // Square
for ( unsigned c = 0; c < size ; c++ ){
if(solid){
cout << " * ";
}
else{
if(r == 0 || r == size-1 || c == 0 or c == size-1){
cout << " * ";
}
else{
cout << " ";
}
}
}
cout <<endl;
}
cout <<endl;
} |