ch7 - 6 cfw_+ @; D : h Z 2 120 h Z + 120 2 int age1, age2,...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
± + {+ :ãD hZˆ¸ª 120 2 2 120 ¸ int age1, age2, age3, …. .. age119, age120 age1=0; age2=0; printf(“%d\n”, age1); …… printf(“%d\n”, age2); age120=0; …... scanf(“%d”,&x); printf(“%d\n”, age120); while((x>0)&&(x<121)){ if(x==1) age1 += 1; else if(x==2) age2 += 1; …… else if(x==120) age120 += 1; scanf(“%d”,&x); } E ix [
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
§7.1 2 ˆZ ˆ ¸ª* int a[10]; 2 a[0], a[1], a[2], …... a[9] 2 int i=3, j=2, a[10]; 2 a[i], a[i+2], a[i+j], …… 2 2 2 2 2 X ³9
Background image of page 2
main() { int a[120], x, i, n=0; for(i=0; i<120; i++) a[i]=0; scanf(“%d”,&x); while( (x>0) && (x<121) ){ a[x-1] = a[x-1] + 1; n++; scanf(“%d”,&x); } printf(“Total people =%d\n”, n); for(i=0; i<120; i++) printf(“%d years old=%d\n”, i+1, a[i]); } v [ ] ˆ1 칪 120 2 a[0], a[1], a[2], …. .. a[119] 1 2 3 120 2 2 ˜V ¸
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
int a[10]; float b[5]; char c[20]; a[0], a[1], …... a[9] b[0], b[1], …... b[4] c[0], c[1], …... c[19] 2 2
Background image of page 4
int a[3]={1 2 3 2 5}; float b[2]={3.14 2 5.18}; char c[5]={‘a’, ‘b’, ‘c’, ‘d’, ‘e’}; d int a[]={1 2 2 2 3 2 4 2 5}; { int b[10]={1 2 2};
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
] int a[20]; a[0] a[1] a[2] a[17] a[18] a[19] ….. 2
Background image of page 6
[ 2 7.1] 2 a[0] 2 a[9] 2 0~9 T ‘ [ 9876543210 main() { int i,a[10]; for (i=0; i<=9; i++) a[i]=i; for(i=9; i>=0; i--) printf(“%d ”, a[i]); }
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
[ 2 7.2] [ Fibonacci [ 20 2 main() { int i; int f[20]={1,1}; for (i=2; i<20; i++) f[i]=f[i-2]+f[i-1]; /* 2 f[2] 2 f[19] */ for (i=0; i<20; i++) { if (i%5==0) printf(“\n”); /* [ 5 2 */ printf(“%12d ”, f[i]); } } 1 2 1 2 2 2 3 2 5 2 8 2 …… f[0], f[1], f[2], f[3], f[4], f[5], ……f[19]
Background image of page 8
[ 2 ] 5 [ [ ˜!6;{+ °Zˆ ¸ª*@ ù 1 2 8 2 5 2 15 2 0 0 2 1 2 5 2 8 2 15 2 1 5 8 0 15 [ [ [ 4 2 [ ... 1 8 5 15 0 1 8 5 15 0 1 5 8 15 0 1 5 8 15 0
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
] n T ¹ª* n-1 2 2 j n-j T[ w / ] 1 2 n-j [ 2 7.3]T 10 0s main() { int a[11]; /* a[0] 2 , 10T a[1] 2 a[10] 2 */ int i,j,t; printf(“intput 10 numbers : \n”); for (i=1; i<11; i++) scanf(“%d”,&a[i]); printf(“\n”);
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 36

ch7 - 6 cfw_+ @; D : h Z 2 120 h Z + 120 2 int age1, age2,...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online