07 zsb C练习上机(一)

  1/*
  2    本文档是关于专升本的C练习的上机实践,于
  3        07 0303  开始做
  4
  5*/

  6
  7#include <stdio.h>
  8#include <string.h>
  9#define SIZE 10
 10#define MA(x) x*(x-1)
 11int x47,y47,x48=1;
 12  /*一选择题*/
 13
 14    /*NO1
 15    info:
 16    */

 17    void NO1()
 18    {
 19    }
/*void NO1*/
 20
 21    /*NO2
 22    info:
 23    */

 24    void NO2()
 25    {
 26    }
/*void NO2*/
 27
 28    /*NO3
 29    info:
 30    */

 31    void NO3()
 32    {
 33    }
/*void NO3*/
 34    
 35
 36    /*NO4
 37    info:  2.构造数据类型构造数据类型
 38
 39  是根据已定义的一个或多个数据类型用构造的方法来定义的。也就是说,
 40    一个构造类型的值可以分解成若干个“成员”或“元素”。每个“成员”都
 41    是一个基本数据类型或又是一个构造类型。在C语言中,构造类型有以下几种:
 42
 43  ·数组类型
 44
 45  ·结构类型
 46
 47  ·联合类型(共用体)
 48    */

 49    void NO4()
 50    { }/*void NO4*/
 51    
 52    
 53    
 54    /*NO5
 55    info:
 56    */

 57    void NO5()
 58    {
 59    }
/*void NO5*/
 60    
 61    /*NO6
 62    info:见<C语言关键字>
 63    */

 64    void NO6()
 65    {
 66    
 67      /*int 3ab,A_10,st; A*/
 68      int class,grade ;
 69      int printf,INT,char1;
 70      /*int b3,a,unsigned;*/
 71 }
/*void NO6*/
 72
 73    /*NO7
 74    info:
 75    */

 76    void NO7()
 77    {
 78     /* double dA=2e3.5;   后面不能是小数*/
 79      
 80      double dB=-5.e-3;
 81      
 82     /* double dC=-e-3; dcC = -1e-3; 前面那个1 也要写出来*/
 83
 84    }
/*void NO7*/
 85
 86    /*NO8
 87    info:
 88    */

 89    void NO8()
 90    {
 91      char a='\x4a';  /*A ASC码为74*/
 92     /* char c = '\084';  C*/
 93
 94        printf("%c",a);
 95    }
/*void NO8*/
 96
 97    /*NO9
 98    info:
 99    */

100    void NO9()
101    {
102
103    }
/*void NO9*/
104    
105    /*Linux中的关于求字符串长度的代码,详细见"linux中的string操作库函数代码.txt"*/
106 int strlenL(const char * s)
107 {
108        const char *sc;
109
110         for (sc = s; *sc != '\0'++sc)
111                 /* nothing */;
112        return sc - s;
113 }

114 
115    
116    /*NO10
117    info:
118    */

119    void NO10()
120    {
121    
122     char *str="m\x4a\\\np\102q";
123       char ch=str[0];
124       int d =0;
125       while(ch!='\0')
126       {
127         d++;
128         ch = str[d];
129       }

130       printf("length of str is:%d",strlenL(str));
131    
132    }
/*void NO10*/
133    
134    
135    
136    /*NO11
137    info:
138    */

139    void NO11()
140    {
141    
142     printf("%d,%d,%d\n",010,0x10,10);
143    
144    }
/*void NO11*/
145    
146    
147    
148    /*NO12
149    info:
150    */

151    void NO12()
152    {
153     int i,j,k,*p;
154     float a,b;
155        /*[1]*/
156
157     ++i; /*A*/
158    /* a = a + b=1; false*/
159     k = p==&j;
160     k = (i = j = 0);
161
162     /*[2]*/
163    i = 0;
164    /* if(a%3) ; 错误 07zsbc~1.c 193: 非法地使用浮点数在 NO12 函数中*/
165    /*if(b=)b = float(i);*/ /*false -->b = (float)i;  true */
166    if(b=(float)i*(a=3))
167         printf("true");
168    else
169        printf("false"); /*结果是false*/
170    if(p = i);
171    }
/*void NO12*/
172
173
174        
175    /*NO13
176    info:
177    */

178    void NO13()
179    {
180        int  a = 10,b = 20;
181        printf("%d",!a<10); /* 1 */
182    }
/*void NO13*/
183    
184    
185    
186    /*NO14
187    info:
188    */

189    void NO14()
190    {
191      int x = 10,z = 19,y;
192      scanf("%d",&y);
193      if(x<=y&&y<=z)
194        printf("y is between x and z");
195       else
196        printf("y is out of x and z");
197
198    
199    }
/*void NO14*/
200    
201    
202    
203    /*NO15
204    info:
205    */

206    void NO15()
207    {
208      int x =4;
209      printf("%d",x+=x*=x+1);
210    }
/*void NO15*/
211    
212    
213    
214    /*NO16
215    info:
216    */

217    void NO16()
218    {
219       int s,p;s = p = 5;
220       p = s++++p,p+2,p++;
221       printf("%d",p);
222
223    
224    }
/*void NO16*/
225    
226    
227    
228    /*NO17
229    info:
230    */

231    void NO17()
232    {
233      int a,b;
234      printf("%d",(a = 4,b = 3,a+b+2,a++,a+b+2));
235
236    
237    }
/*void NO17*/
238    
239    
240    
241    /*NO18
242    info:  注意
243    */

244    void NO18()
245    {
246    
247     float a = 3.0,b = 4.0,c = 5.0;
248     printf("%f",1/2*(a+b+c));
249
250    
251    }
/*void NO18*/
252    
253    
254    
255    /*NO19
256    info:
257    */

258    void NO19()
259    {
260     double d= 3.2;
261     int x,y;
262     x = 1.2;
263     y = (x+3.8)/5.0 ; /*x等于1*/
264     printf("y:%d\n",y);
265     printf("d/d:%f\n",d/d);
266     printf("d/d:%d\n",d/d);
267
268    
269    }
/*void NO19*/
270    
271    
272    
273    /*NO20
274    info:
275    */

276    void NO20()
277    {
278    int k = 17;
279    printf("%d,%o,%x\n",k,k,k);
280    }
/*void NO20*/
281    
282    
283    
284    /*NO21
285    info:
286    */

287    void NO21()
288    {
289       int a,b,c;
290       a = b = c = 1;
291      ++b&&++c||++a;
292      printf("a=%d,b=%d,c =%d\n",a,b,c);
293
294    
295    }
/*void NO21*/
296    
297    
298    
299    /*NO22
300    info:
301    */

302    void NO22()
303    {
304     int m,n,x;
305     m = 6;
306     n = 5;
307     x=--m==n++?--m:++n;
308     printf("x = %d,m =%d,n = %d",x,m,n);
309
310    
311    }
/*void NO22*/
312    
313    
314    
315    /*NO23
316    info:
317    */

318    void NO23()
319    {
320      printf("a\bre\'hiy\\\bou\n");
321
322    
323    }
/*void NO23*/
324    
325    
326    
327    /*NO24
328    info:
329    */

330    void NO24()
331    {
332      int x;
333      float y;
334      char z[10],c;
335      scanf("%3d%f%3s%c",&x,&y,z,&c);
336      printf("x=%d\ny=%f\n,z=%s\nc=%c",x,y,z,c);
337
338    
339    }
/*void NO24*/
340    
341    
342    
343    /*NO25
344    info:
345    */

346    void NO25()
347    {
348
349     int a[SIZE]; /*A*/
350     int n;
351
352    }
/*void NO25*/
353    
posted @ 2007-03-10 22:09  刘寅  阅读(506)  评论(1)    收藏  举报