#include <stdio.h>
void main(){
int a[] = {10, 5, 9, 1, 3, 4, 7, 2, 8, 6, 0};
int i;
int total = 0;
for ( i = 0 ; a[i] ; i++ )
total+= a[i];
printf("total : %d\n", total);
}
|
#include <stdio.h>
void main(){
int a[] = {10, 5, 9, 1, 3, 4, 7, 2, 8, 6, 0};
int *p;
int total = 0;
p = a;
while(*p)
total+= *(p++);
printf("total : %d\n", total);
}
|