【正文】
3 18 4 95 5 14 6 90 7 70 8 60 9 37 Copyright 19922020 by Deitel amp。 / * n i s a n a r r a y o f 1 0 i n t e g e r s * / 9 i n t i 。 i 10 。 / * s e t e l e m e n t a t l o c a t i o n i t o 0 * / 14 } / * e n d f o r * / 15 16 p r i n t f ( % s % 1 3 s \ n , E l e m e n t , V a l u e )。 i 10 。 21 } / * e n d f o r * / 22 23 r e t u r n 0 。 Associates, Inc. and Pearson Edition Inc. All right Reserved. Element Value 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 Copyright 19922020 by Deitel amp。 ? 程式設(shè)計(jì)師不小心使用的 a[10] 去存取一個(gè)不存在的記憶體空間 for(i=0。i++) a[i]=0。 11 int i。 / * i nn er c ou n te r */ 13 14 pr in tf ( % s %1 3s %1 7s \ n , E l em en t , V a lu e , Hi st og ra m )。 i SI Z E 。 19 20 f or ( j = 1 。 j+ + ) { / * pr in t o ne b ar * / 21 pr in t f( % c , 39。 )。 Associates, Inc. and Pearson Edition Inc. All right Reserved. Element Value Histogram 0 19 ******************* 1 3 *** 2 15 *************** 3 7 ******* 4 11 *********** 5 9 ********* 6 13 ************* 7 5 ***** 8 17 ***************** 9 1 * 24 p r i n t f ( \ n ) 。 / * i n d i c a t e s s u c c e s s f u l t e r m i n a t i o n * / 28 29 } / * e n d m a i n * / Copyright 19922020 by Deitel amp。 / * c o u n t e r * / 11 int r a t i n g 。 15 16 / * p l a c e s u r v e y r e s p o n s e s i n a r r a y r e s p o n s e s * / 17 int r e s p o n s e s [ R E S P O N S E _ S I Z E ] = { 1 , 2 , 6 , 4 , 8 , 5 , 9 , 7 , 8 , 10 , 18 1 , 6 , 3 , 8 , 6 , 10 , 3 , 8 , 2 , 7 , 6 , 5 , 7 , 6 , 8 , 6 , 7 , 5 , 6 , 6 , 19 5 , 6 , 7 , 5 , 6 , 4 , 8 , 6 , 8 , 10 } 。 Associates, Inc. and Pearson Edition Inc. All right Reserved. Rating Frequency 1 2 2 2 3 2 4 2 5 5 6 11 7 5 8 7 9 1 10 3 21 / * f o r e a c h a n s w e r , s e l e c t v a l u e o f a n e l e m e n t o f a r r a y r e s p o n s e s 22 a n d u s e