Jump to content
Sign in to follow this  
encik pot pet

Aktiviti Pengaturcaraan C

Recommended Posts

Berkenaan soalan² cade

Soalan 1: [EDIT] dah betulkan error dah, tapi masalahnya out put yg kita nak tu, xder, hanya kuar arahan mintak input user saja.... jadi ntah mana lagi yg tak betulnya wacko.gif

Soalan 2:

{

    for (int x=1;x<6;x++){

        for (int y=1;y<=x;y++)       

    cout<<y;

    cout<<endl;

}

pendekkan lagi

{ for (int x=0;x<5;x++)
   for (int y=1;y<[x+1];y++)
   cout<<y<<endl;}

::kurang satu baris saja ph34r.giftongue.gif ::

Edited by mfar

Share this post


Link to post
Share on other sites

wohhh..sampai ke pagi wat assignment..... soklan no 1c camner ek... ??? Pening aaaa.. bagi tip sket...baru blajar sampai "if" statement.... dia ada guna function lain ke..? atau aku ni lembab sangat...aaahhh tiu laa.... BTW..ni jwp yg aku dah buat...

No 1a :

{
    for (int x=1;x<6;x++){
    for (int y=1;y<=x;y++)
    cout<<"$";
    cout<<endl;
}
No 1b :
{
    for (char x='F';x>='A';x--){
    for (char y='F'; y>=x; y--)
    cout<<y;
    cout<<endl;
}
No 1d :
{
    for (int x=1;x<=6;x++){
    for (int y=6;y>=x;y--)
    cout<<"*";
    cout<<endl;
}

hmmmm......Soklan no 2 dalam proses...sangkut kat soklan no 1c puaka tu...heehehehe

Hmmmm....gila babeng tul...donlod tutorial.... ingat sket jek...bila dah siap print...tu dia...tebal gila....heheheheheh.....

user posted image

Edited by Vibrunnica

Share this post


Link to post
Share on other sites

wohhh..sampai ke pagi wat assignment..... soklan no 1c camner ek... ???

nih ha, aku kasi coding ala budak freshie.... baru buat smalam ph34r.gif

#include <iostream.h>
#include <conio.h>
void main()
{
char h[5]="ABCDE";
int x,y1,y2,z;

for(x=0;x<5;x++){
for(z=4;z>x;z--)
cout<<" ";
for(y1=0;y1<x;y1++)
cout<<h[y1];
for(y2=x;y2>=0;y2--)
cout<<h[y2];
cout<<endl;}
getch();}

Mati² nak buat gelung dalam gelung dalam gelung ohmy.gif last² gelung banyak² dlm satu gelung besar jer laugh.gif

Sendiri punya dah dapat ke?

Share this post


Link to post
Share on other sites

ok la... code mfar tak ikut standard.. so aku just repair la sket tambah indentation

#include <iostream>

using namespace std;

int main()
{
	char h[]="ABCDE";
	int x, y1, y2, z;

	for(x=0; x<5; x++) {
  for(z=4; z>x; z--)
  	cout<<" ";
  for(y1 = 0; y1< x; y1++)
  	cout<<h[y1];
  for(y2 = x; y2 >= 0; y2--)
  	cout<<h[y2];
  cout<<endl;
	}

	return 0;
}

Share this post


Link to post
Share on other sites

ok la... code mfar tak ikut standard.. so aku just repair la sket tambah indentation

Mmglah tak ikut standard MSVC (Ms Visual C++) sbb aku pakai Borland C++.. tapi, it's ok for MSVC users for adding apa yg kurang bg coding versi Borland tu...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...