Post

note_8_16

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Created on iPhone.

#include <stdio.h>
int test_p108_20()
{
   int i,x,y;
   i=x=y=0;
   do{
      ++i;
      if(i%2!=0)
      {
         x=x+i;
         i++;
      }
      y=y+i++;
   }while(i<=7);
   printf("x = %d,y = %d\n",x,y);

}
int test_p107_16()
{
   int x,y;
    x=y=0;
    while(x<15) y++,printf("x: %d y: %d\n",x,y), x+=++y,printf("---x: %d ---y: %d\n",x,y);
    printf("%d %d\n",y,x);
    return 0;
}
int test_p106_10()
{
   int digit,number;
   scanf("%d",&number);
   while(number)
   {
      digit = number%10;
      number/=10;
      printf("%d",digit);
   }
   printf("\n1%%10: %d\n",1%10);
   printf("1//10: %d\n",1/10);
   return 0;
}
int test_p106_9()
//sitch语句 在没有break语句的情况下
//只要前面有一个匹配了
//后面的case语句都会执行!!!
{
   int i;
   for(i=0;i<3;i++)
   {
      switch(i)
      {
         case 0:printf("++%d\n",i);
         case 2:printf("__%d\n",i);
         default:printf("**%d\n",i);
      }
   }
   return 0;
}
int test_p106_8()
//for循环注意看分号
{
   int s,i;
   for(s=0,i=1;i<3;i++,s+=i,printf("%d\n",s));

   return 0;
}
int main() {
   setbuf(stdout, NULL);
 //  test_p106_8();
   //etest_p106_9();
   //test_p106_10();
   //test_p107_16();
   test_p108_20();
   return 0;
}

This post is licensed under CC BY 4.0 by the author.