while cycling exercise

  1  / * 
  2  1. 1 to seek between all odd and m
   3  2. greatest common divisor of two numbers and the least common multiple
   . 4  3. Receive a character string from the keyboard cycle, and count the number of letters, spaces, numbers and other characters, the input end of the transport path
   5  sequence.
  6  4 Monkey off his first day of a number of peach, half eaten immediately, not good enough to eat one.
  7  the next morning in turn eaten the rest of the peaches in half, or not fun to eat another one. After a day before the rest of the day eat half a plus.
  8  to day 10 just left a. I asked the monkey off the first day how many peaches?
  9  5 9 9 * print multiplication table
 10  6 Print pattern follows while loop
 . 11  . 1
 12 is  2. 3
 13 is  . 4. 6. 5
 14  . 7. 9 10. 8
 15  . 11 14 15 12 is 13 is
 16  7 Xiaofang's mother gave her 2.5 yuan a day, she would save up, but every time this day is to save money on day 5 or a multiple of 5, then
 17  she would spent 6 yuan. I ask, how many days after Xiaofang can save up to 100 yuan.
18 8. The use of a while loop, splicing two strings.
. 19  
20 is  * / 
21 is  
22 is #include <stdio.h>
 23 is  
24  // 1. request from 1 to m and odd all 
25  void jishusum ( int m) {
 26 is      int SUM = 0 , I = 0 ;
 27      the while (I < m) {
 28          IF (% I 2 =! 0 )
 29              SUM = + I;
 30          I ++ ;
 31 is      }
 32      the printf ( " SUM D =% \ n- ", SUM);
 33 is  }
 34 is  // 2. greatest common divisor of two numbers and the least common multiple of 
35  void gongbeishu () {
 36  
37 [  }
 38 is  // receiving loop string from the keyboard, and the statistics letters, spaces, and other digital the number of characters, press enter the program ends. 
39  void panduan () {
 40      int zimu = 0 , Shuzi = 0 , kongg = 0 , qita = 0 ;
 41 is      char C;
 42 is      the while (! (C = getchar ()) = ' \ n- ' ) {
 43 is          IF (C > = 97 && C <= 122 || C> =65 && c <= 90) {
 44             zimu++;
 45         }
 46         else if (c >= 48 && c <= 57) {
 47             shuzi++;
 48         }
 49         else if (c==32) {
 50             kongg++;
 51         }
 52         else {
 53             qita++;
 54         }
 55     }
 56     printf("There letters:% d figures are:% d space has:% d others:% d \ n- " , zimu, Shuzi, kongg, qita);
 57 is  }
 58  // monkeys off the first day of a number of peaches, immediately eat half, not good enough to eat one.
 59  // the next morning turn the rest of the half-eaten peach, or not fun to eat another one. plus half a day before the rest of the day to eat later .
 60  @ to 10 days just left the first day of a monkey asked how many pick peaches.?
 61 is  // X / 2 +. 1   
62 is  void houzi () {
 63 is      int NUM = . 1 ;
 64      int I = . 1 ;
 65      the while (I < 10 ) {
 66          NUM = . 1 + (NUM * 2 + . 1 );
67          I ++ ;
 68      }
 69      the printf ( " % D " , NUM);
 70  }
 71 is  // print the following patterns while loop 
72  / * 
73 is  . 1
 74  2. 3
 75  . 4. 5. 6
 76  . 7. 8. 9 10
 77  . 11 12 is 13 is 14 15
 78  * / 
79  void printshuzi () {
 80      int I = . 1 , K = . 3 ;
 81      // the printf ( ". 1 \ n-"); 
82      the while (I <= 15 ) {
83          IF (I == 2 || I == . 4 || I == . 7 || I == . 11 ) {
 84              the printf ( " \ n- " );
 85          }
 86          the printf ( " % D " , I);
 87          ++ I ;
 88      }
 89      
90  }
 91 is  // while loop, splicing two strings. 
92  void pinjie () {
 93      char S1 [ 10 ] = { " WOAI " }, S2 [10]="zhongguo", s[250];
 94     int lens1 = sizeof(s1) / sizeof(char);
 95     int lens2 = sizeof(s2) / sizeof(char);
 96     //int lens1 = sizeof(s1) / sizeof(char);
 97 
 98     int i = 0,k=0;   //s=s1+s2
 99     while (i < lens1) {
100         s[i] = s1[i];
101         if (s1[i] == '\0') {
102             while (k < lens2) {
103                 s[i] = s2[k];
104                 k++;
105                 i++;
106             }
107         }
108         i++;
109     }
110 }
111 //打印 9*9 乘法表
112 void chengfa() {
113     int i=1, j;
114     while (i <= 9)
115      {
 1 16          J = . 1 ;
 117          the while (J <= I) {
 1 18              the printf ( " % D *% D =% D     " , J, I, I * J);
 119              J ++ ;
 120          }
 121          the printf ( " \ n- " );
 122          I ++ ;
 123      }
 124  }
 125  / * 
126  Xiaofang her mother 2.5 yuan per day, she will be kept up, but when the day is the day 5 to save money or if multiples of 5,
 127  she will spent 6 yuan. I ask, how many days after Xiaofang can save up to 100 yuan.
128  * /
129 void cunqian() {
130     int money = 0;
131     int day=1;
132     while (money<=100) {
133         money = 2.5*day;
134         if (day >=5 && day % 5 == 0) {
135             money -= 6;
136         }
137         day++;
138     }
139     printf("存到100需要%d天", Day);
 140  }
 141 is  int main () {
 142      Chengfa ();
 143      // cunqian ();
 144      // pinjie ();
 145      // printshuzi ();
 146      // houzi ();
 147      // panduan ( );
 148      // jishusum (10); 
149      System ( " PAUSE " );
 150      return  0 ;
 151 }
View Code

 

Guess you like

Origin www.cnblogs.com/pufan/p/12169889.html