5, no more than 5 enter a positive integer programming: it is determined few, each digital outputs.

. 1 #include <stdio.h>
 2 #include <math.h>
 . 3  int flws ( int );
 . 4  void main ()
 . 5  {
 . 6      int n-, J, K = 0 ;
 . 7      the printf ( " Enter a positive integer: \ n- " );
 . 8      Scanf ( " % D " , & n-);
 . 9      J = n-;
 10      the while ! (J = 0 )   // to take place 
. 11      {
 12 is          J / = 10 ;
 13 is         K ++ ;
 14      }
 15      IF (K <= . 5 )
 16          flws (n-, K);
 . 17      the else 
18 is          the printf ( " the number of bits is greater than 5 \ n-. " );
 . 19  }
 20 is  int flws ( int n-, int K) 
 21 is  {
 22 is      int B, FL, I = . 1 ;
 23 is      the while ! (K = 0 )
 24      {    
 25          B = POW ( 10 , - K- . 1 ); //Using pow function takes n-1 bit bit weight 
26 is          FL = n-/ B;
 27          n-% = B;
 28          the printf ( " % d of the number of bits of% d \ n- " , I, FL);
 29          - K- -, I ++ ;
 30      }
 31 is      return  0 ;
 32 }



1  // 5, no more than 5 inputs a positive integer programming: it is determined few, each digital outputs. 
2 #include <stdio.h>
 . 3 #include <math.h>
 . 4  void main ()
 . 5  {
 . 6      int n-, I, J, K, B, F;
 . 7      K = 0 ;
 . 8      Scanf ( " % D " , & n-);
 . 9      J = n-;
 10      the while ! (J = 0 )   // take the first number of bits to K 
. 11      {
 12 is          K ++ ;
 13 is         J / = 10 ;
 14      }
15      F = POW ( 10 , - K- . 1 );   // take the highest bit weight 
16      the printf ( " The number of bits has% d \ n- " , K);
 . 17      IF (K> . 5 || n-<= 0 ) the printf ( " the number is not less than 5 positive integer \ n- ' );
 18 is          the else  for (I = . 1 ; I <= K; I ++) // Low to take place 
. 19          {
 20 is              B = n-/ F; // taking the highest bit every time 
21 is              n-n-% = F; // remove the highest bit 
22 is              F / = 10 ;   //Change the bit weight 
23 is              the printf ( " % d of the number of bits of% d \ n- " , I, B);
 24          }
 25  
26 is }

There is a method stupid ratio:

1  / * 5, no more than 5 inputs a positive integer,
 2  programming: it is determined few,
 3  outputs each digit. * / 
. 4 #include <stdio.h>
 . 5  void main ()
 . 6  {
 . 7      int n-, J, I, K, COUNT, F;
 . 8      K = 0 ;
 . 9      Scanf ( " % D " , & n-);
 10      J = n-;
 . 11      the while (J =! 0 )   // take the first number of bits to K 
12 is      {
 13 is          K ++ ;
 14         J / = 10 ;
15      }
 16      the printf ( " The number of bits has% d \ n- " , K);
 . 17      IF (K> . 5 || n-<= 0 ) the printf ( " The number is not less than 5 positive integer \ n- " );
 18 is      the else  for (I = . 1 ; I <= K; I ++) // Low to take place 
. 19      {
 20 is          F = n-;
 21 is          for (I = COUNT; COUNT <= K; ++ COUNT )
 22 is          {
 23 is                  J = F% 10 ;
 24                  F / = 10 ;
 25     
26 is          }
 27          the printf ( " The first number is% d% d \ n- " , I, J);
 28      }
 29  
30 }

 

 

 

 

Guess you like

Origin www.cnblogs.com/BK-yushen/p/11961866.html