Input a number between 1-9, then choose 2 character, e.g: * and =.
The sample output:
Enter number: 5
Enter character: * =
*
==
***
====
*****
I had tried many times, but don't know where i was doing wrongly. Please help, thanks!:)
#include <iostream>
using namespace std;
int main()
{
int x,i,j;
char ch1, ch2;
cout<<"Please enter any 2 characters."<<endl;
cin>>ch1>>ch2;
cout<<"Please input an number."<<endl;
cout<<"(between 1-9)"<<endl;
cin>>x;
if (x>0 && x<=9)
{
bool isOdd;
for (i=0; i<x; i++)
{
isOdd=false;
for (i=0; i<x; i++)
{
if ((x%2)==1)
isOdd=true;
}
}
if (isOdd)
{
cout<<ch1<<endl;
i++;
}
else
{
for (j=0; j<i; j++)
{
cout<<ch2<<endl;
j++;
}
}
}
else
{
cout<<"Error!"<<endl;
}
return 0;
}