#include <stdlib.h>
int main(int argc, char *argv[]) {
//陣列(Array)
//ary[3] 表示 陣列大小為3 (ary[0], ary[1], ary[2])
int ary[];
ary[0] =5;
ary[1] =10;
ary[2] =15;
printf("總和:%i\n", ary[0]+ary[1]+ary[2]);
//越來越簡短
int ary_2[]={5, 10, 15};
int i;
//ary_2[]內有num個
int num = sizeof(ary_2)/sizeof(int);
for(i=0; i< num; i++){
printf("index%i內容為:%i\n",i ,ary_2[i]);
}
return 0;
}
沒有留言:
張貼留言