### rectangle

EDIT: It appears the OP has swum away.

 Can someone write the whole cod please?

Ah, yes, seen this post before. http://www.cplusplus.com/forum/beginner/265416/#msg1143024

@Reshgod
(1) please don't double-post: it prompts ire rather than code;
(2) it's not the most difficult assignment under the sun - please have a try first.
http://www.cplusplus.com/doc/tutorial/control/#for
Last edited on
This should be close to what you asked for. Such simple starter programs (typically < 10 total lines) I will help with but you need to start trying and learning or you will soon ask things I refuse to help with.

 ``123456789101112131415`` ``````using namespace std; int main() { int a,b; cin >> a >> b; for(int i = 1; i <=a*b; i++) { cout << (i%b ? "x" :"x\n"); } if(a!=1&&b!=1) cout<< a + a-2 + b-1+b-1 << endl; else cout << a*b << endl; }``````

while you are working on it you can double check my perimeter count logic. I think it works but I only tested a few basic cases. Whole thing goes wrong if you type in negatives / junk of course. It works for 1x1, 1x2, 2x1, and 2x2 and bigger as far as I can tell.
Last edited on
We could write the program for you, but that would not help you to learn.
kids these days. Even when you give them the code, they still get all worked up.
I wouldn't mind, @Jonnin, but I'd written everything he asked for!

Reshgod wrote:
Can someone write the whole cod please?
Reshgod wrote:
I must use for.

 ``123456789101112131415161718`` ``````#include #include using namespace std; double fish( int x ) { double xx = ( x - 16 ) * ( x - 16 ); return abs( x < 16 ? sqrt( 64.0 - xx / 4.0 ) : 8 - 0.01 * xx ); } int main() { for ( int j = 8; j >= -8; j-- ) { for ( int i = 0; i < 56; i++ ) cout << ( abs( j ) <= fish( i ) ? '*' : ' ' ); cout << '\n'; } }``````

 ``` * ****************** * ************************* ** ****************************** *** ********************************** ***** ************************************* ****** **************************************** ******** ****************************************** ********** ******************************************************** ****************************************** ********** **************************************** ******** ************************************* ****** ********************************** ***** ****************************** *** ************************* ** ****************** * * ```

ROFL!

OK, lastchance, you won the internet today.
Nice! I started to do a fish, I saw the cod thing, then my mind found other ways to use that word, and I gave in and just drew a rectangle to be safe.

That code to do the fish is outstanding!
Last edited on
Thatâ€™s awesome!
That fish code is so cool I bookmarked the post.
Topic archived. No new replies allowed.