is it possible?

i wrote a code that shows a RHOMBIC with equal diameters...
is it possible to show a RHOMBIC with different diameters???
((only using loops))



my code :



#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int h,s,d;
loop:cout<<"d=";
cin>>d;
if(d<80)
{
for(h=0;h<=d/2;h++)
{
for(s=d/2-h;s>=1;s--)
cout<<" ";
cout<<"*";
for(s=2*h-1;s>=1;s--)
cout<<" ";
if(h>0)
{
cout<<"*";
}
cout<<"\n";
}
for(h=d/2-1;h>=0;h--)
{
for(s=d/2-h;s>=1;s--)
cout<<" ";
cout<<"*";
for(s=2*h-1;s>=1;s--)
cout<<" ";
if(h>0)
{
cout<<"*";
}
cout<<"\n";
}
}
else
{
cout<<"enter lower than 80";
}
goto loop;
getch();
return 0;
}


Of course you can. You just need to get the ratio between the diagonals, and then scale your for loops. (s = d/2-h becomes s = (d/2-h)*ratio , however s=2*h-1 becomes s=(2*h)*ratio-1)

Also, don't use goto. It's harmless now, but when your programs will get bigger it will cause a lot of confusion. You can do the same thing with one big while(true) loop.
You don't need that getch(). Your program will never reach that point. Also, you're using two libraries to do one thing. If you need to pause, use cin.get() instead.
When posting code, use [code] tags and some indentation. That would make your code a lot easier to read.
And lastly, I don't thing that shape is called RHOMBIC. Maybe rhomb or diamond. So says wikipedia..
Hi,

do you program like this? Cause this way kinda sucks...
Could you please repost your code, using [code ] and [/ code] (without the spaces)..

Don't get me wrong, I do want to help you (if I can). However, if I can't read it without having to search where one loop ends and another starts (or just without a clear view on the code), it's way harder to help you then it should be...

Cheers! (:
Topic archived. No new replies allowed.