Here is your code indented with code tags.
One problem with your function is that you never declared s1 and s2.
Below code fixes that :
#include <iostream>
using namespace std;
void drawShape(int nrP)
{
int s1 = 0,s2 = 0; //(NEW)
for (int i = 1; i <= nrP; i++)
{
s1 = i - 1;
s2 = (2 * nrP - 2 * i - 1);
for (int j = 1; j <= s1; j++)
cout << '^';
cout << '#';
for (int j = 1; j <= s2; j++)
cout << '^';
cout << '#';
for (int j = 1; j <= s1; j++)
cout << '^';
cout << endl;
}
}
int main()
{
int nr = 0;
cout << "Number of rows: ";
cin >> nr;
drawShape(nr);
return 0;
}
Last edited by firstPerson; Sep 19th, 2009 at 1:12 pm.
Reputation Points: 840
Solved Threads: 594
Senior Poster
Offline 3,862 posts
since Dec 2008