Jump to content
johntheripper

Jom Blajar C...

Recommended Posts

aku x tau apa dah jadi ngan code ni :D, tapi cam berterabur jek..aku nk buat output cam ni.

rasa2 cam senang je...tapi dah tak ingat..mana yg x kena yek?

1 2

1 2

1 2

#include<stdio.h>

#define baris 3

#define lajur 2

int main(void)

{

int i,j,matrix[baris][lajur];

printf("\n---Masukkan unsur2 matix---\n");

for (i=0;i<baris;i++)

{

for (j=0;j<lajur;j++)

{

printf("\nMasukkan matrix [%d][%d] : ",i,j);

scanf("%f",&matrix[j]);

}

}

for (i=0;i<baris;i++)

for (j=0;j<lajur;j++)

{

printf("%d",&matrix);

}

}

Edited by ntxploits

Share this post


Link to post
Share on other sites

for (i=0;i<baris;i++)

for (j=0;j<lajur;j++)

{

printf("%d",&matrix);

}

}

tukar jadi...

for (i=0;i<baris;i++)

for (j=0;j<lajur;j++)

{

printf("%d",matrix[j]);

}

}

Share this post


Link to post
Share on other sites

aku dah tukar....& ini output dia...

D:\C\array>08

---Masukkan unsur2 matix---

Masukkan matrix [0][0] : 1

Masukkan matrix [0][1] : 1

Masukkan matrix [1][0] : 1

Masukkan matrix [1][1] : 1

Masukkan matrix [2][0] : 1

Masukkan matrix [2][1] : 1

229356822935682293568229356822935682293568

D:\C\array>

pas tu aku try tukar sket lagi....

#include<stdio.h>

#define baris 3

#define lajur 2

int main(void)

{

int i,j,matrix[baris][lajur];

printf("\n---Masukkan unsur2 matix---\n");

for (i=1;i<=baris;i++)

{

for (j=1;j<=lajur;j++)

{

printf("\nMasukkan matrix [%d][%d] : ",i,j);

scanf("%f",&matrix[baris][lajur]);

}

}

for (i=1;i<=baris;i++)

{

for (j=1;j<=lajur;j++)

{

printf("%d",&matrix[baris][lajur]);

}

printf("\n");

}

}

tapi jadi cam ni pulak...

D:\C\array>05

---Masukkan unsur2 matix---

Masukkan matrix [1][1] : 1

Masukkan matrix [1][2] : 1

Masukkan matrix [2][1] : 1

Masukkan matrix [2][2] : 1

Masukkan matrix [3][1] : 1

Masukkan matrix [3][2] : 1

22936002293600

22936002293600

22936002293600

kalu boleh nk bagi dia punya output cam ni...

1 1

1 1

1 1

Share this post


Link to post
Share on other sites

saya tak check loop awak. tapi others info - & adalah address operator. Buangkannya dari printf statement awak. Basically awak printing address array element awak, bukannya kandungan array tersebut. Gunakan "%d " dalam printf awak untuk dapatkan space.

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...

×
×
  • Create New...