|
 |
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
 |
กระทู้ #1475 [C] (จาก IP: 58.9.187.226)
ช่วยดูให้หน่อยครับ ถูกรึปล่าว
โจรท์มางี้ Section 5.8 Multidimensional Arrays 5.18* (Summing all the numbers in a matrix) Write a method that sums all the intergers in a matrix of integers. Use {{1,2,4,5},{6,7,8,9},{10,11,12,13},{14,15,16,17}} to test the method.
ทำsourcecode ออกมาได้งี้ แก้ไขยังไง ช่วยทีครับ
#include <stdio.h> #include <conio.h>
void main(void) { int num[4][4],i,j,count=0; for(i=0;i<2;i++){ for(j=0;j<3;j++){ ++count; num[i][j]=count; printf("num[%d][%d][%d]=%d\t",i,j,num[i][j]); } printf("\n"); } printf("This resilt confirm array num[4][4]can keep %d value",count); getch(); }
|
จากคุณ
:
Kizzz / kidchamp_007@hotmail.com [2007-10-08 14:33:28]
|
|
ความคิดเห็น #26143 (จาก IP: 58.64.126.81)
ดูตัวอย่างที่แก้ ด้านล่างน่ะคับ ^ ^
#include <stdio.h> #include <conio.h> int main(int argc, char* argv[]) { int i,j; int sum = 0;
int num[4][4] = {{1,2,4,5},{6,7,8,9},{10,11,12,13},{14,15,16,17}}; for(i=0;i<4;i++) { for(j=0;j<4;j++) { sum = num[i][j] + sum; printf("num[%d][%d] = %d, sum = %d\n", i, j, num[i][j], sum); } } printf("This resiult summation of array = %d\n",sum); getchar(); return 0; } //---------------------------------------------------------------------------
|
จากคุณ
:
bird / bird_aw@yahoo.com [2007-10-11 13:24:42]
|
 |
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
|
|