|
i nead help wiht my homework, i need to make this
-------*
------***
---- *****
(the triangle only)
and i have to use set width and the while loop
#include <iostream>
#include <iomanip>
using namespace std;
int count=0;
int sum=0;
int num;
int line=1;
int main()
{
while(count<4)
{
cout<<"put how many spaces you want for line " <<line<"for the *"<<endl;
cin>>num;
sum=sum+num;
line++;
count++;
}
cout<<setw(num)<<"*"<<endl;
return 0;
}
can someone plz give me and idea of how to do it?, i know this is wrong plz hepl
|
|
|
void main()
{
int l=0,z,n,i,k,j;
clrscr();
printf("enter the number of lines :");
scanf("%d",&n);
z=n;
for(i=1;i<(2*n);i=(i+2))
{
l++;
printf("\t\t");
for(k=z;k>1;k--)
{
printf(" ");
}
z--;
for(j=1;j<=i;j++)
{
if(j==1||j==i)
printf("1");
else if (l>=2)
printf ("TRIANGLE:%d",l);
}
printf("\n");
}
getch();
}
|
|
|
|
|
|
|
// |