View: 2472|Reply: 3
|
Nested FOR loops...meh tlg
[Copy link]
|
|
umm...nak minta tlg camner ek nak wat program nested FOR loops utk dptkan output die yg camnie,
****** ******
***** *****
**** ****
*** ***
** **
* *
stakat nih kita cuma dpt btk yg pertama jer,biler nak wat btk yg kedua je dia x dpt nak letak secara bersebelahan.
thank ye pd sesape yg dpt tlg...kita nie br jer blajar c++. |
|
|
|
|
|
|
|
#include<iostream.h>
class Task {
public:
void DisplayDetail();
};
//class Task
void Task::DisplayDetail()
{ int i=2,j,k=0;
for (i=15;i>=1;i--)
{ for (j=i;j>=1;j--)
cout<<"I";
for (j=0;j<k;j++)
cout<<" ";
for (j=0;j<k;j++)
cout<<" ";
k=k+1;
for (j=i;j>=1;j--)
cout<<"I";
cout<<"\n";
};
};
int main()
{
//create a new instance of a class Task
Task word;
//invoke a method
word.DisplayDetail();
return 0;
}; |
Rate
-
1
View Rating Log
-
|
|
|
|
|
|
|
Originally posted by orang_letrik at 19-10-2006 11:28 PM
#include<iostream.h>
class Task {
public:
void DisplayDetail();
};
//class Task
void Task:isplayDetail()
{ int i=2,j,k=0;
for (i=15;i>=1;i--)
{ for (j=i;j>=1;j--)
...
thnx a lot....:tq::tq:
Selamat Hari Raye..... |
|
|
|
|
|
|
| |
|