CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2473|Reply: 3

Nested FOR loops...meh tlg

[Copy link]
Post time 19-10-2006 11:16 PM | Show all posts |Read mode
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++.
Reply

Use magic Report


ADVERTISEMENT


Post time 19-10-2006 11:28 PM | Show all posts
#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

Reply

Use magic Report

Post time 20-10-2006 07:02 AM | Show all posts
Reply

Use magic Report

 Author| Post time 20-10-2006 07:48 AM | Show all posts
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.....
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT


Forum Hot Topic

 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

29-12-2024 12:22 AM GMT+8 , Processed in 0.053719 second(s), 18 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list