hello..
I have a problem, I bet with my friend to complete a program but so far I have not done, this example program ( http://www.mediafire.com/?12naykpi66fvkz6 )I do not know what should be typed. Thanks..
I'm sorry, this is not a virus, it's just a sample program, I just want to know the source code to create this program. I would insert his image. < http://tinypic.com/view.php?pic=168bwjb&s=5 >.
if I input the numbers even higher with the program it will be refused and asked to enter again, and input should be less than 10. output should be shaped like this (http://tinypic.com/view.php?pic=28useas&s=5 )
Again, very sorry. We normally don't do entire projects for people. For all we know this is a homework assignment for you to learn how to do this, and making it for you defeats that purpose.
As a general rule, never ask for full source code and always try to resolve yourself. If you get stuck, then post the piece of code where you are stuck and ask help for that specific problem.
void main ()
{
int sisa, n, a, b;
Home:
clrscr();
cout<<"Input Numbers: ";
cin>>n;
sisa = n%2;
cout<<"\n";
if(sisa==0)
{
for (a = 1; a <= n; a++)
{
for (b = n; b >= a; b--)
{
cout<<" ";
}
for (b = 1; b <= a; b++)
{
cout<<"*";
}
for (b = (a-1); b >= 1; b--)
{
cout<<"*";
}
cout<<"\n";
}
for (a = 1; a <= n-1; a++)
{
for (b = 0; b <= a; b++)
{
cout<<" ";
}
for (b = 1; b <= (n-a); b++)
{
cout<<"*";
}
for (b = (n-a-1); b >= 1; b--) {
cout<<"*";
}
cout<<"\n";
}
Since I don't think there is a std::center for center alignment of output, you should create a function that returns a std::string that centers the text in the desired column width.
std::string CenterText(const std::string &input, int colWidth);
So you would build the individual strings inside a loop and then you would pass them on to CenterText() that will add the necessary number of spaces left and right to the input string and will return the input string padded with the spaces so it looks centered in the console.