Home > Back-end >  C language programming
C language programming

Time:09-17

From the keyboard to enter a positive integer programming statistics the number of digits, and the positive output

CodePudding user response:

With a stack memory bits, ten, hundred figures, etc., to reverse the output,

CodePudding user response:

reference 1st floor ooolinux response:
with a stack memory bits, ten, hundred figures, etc., to reverse the output,

How to write the program

CodePudding user response:

refer to the second floor qq_44217037 response:
Quote: refer to 1st floor ooolinux response:
with a stack memory bits, ten, hundred figures, etc., to reverse the output,

How to write the program


Simple point you can use an array instead of the stack, the first program to write their own ~

CodePudding user response:

reference 1st floor ooolinux response:
with a stack memory bits, ten, hundred figures, etc., to reverse the output,

Too much trouble, as long as the transformed into string, calculate the length of the string, is ok,

CodePudding user response:

reference 4 floor response:
Quote: refer to 1st floor ooolinux response:

With a stack memory bits, ten, hundred figures, etc., to reverse the output,

Too much trouble, as long as the transformed into string, calculate the length of the string, and


It seems that his subject is edited.

CodePudding user response:

reference ooolinux reply: 3/f
Quote: refer to the second floor qq_44217037 response:

Quote: refer to 1st floor ooolinux response:
with a stack memory bits, ten, hundred figures, etc., to reverse the output,

How to write the program


Simple point you can use an array instead of the stack, the first program to write their own ~

Is not did ask luo, hey hey

CodePudding user response:

Use a for loop, and then define a n, n is the number of a for loop, until the positive integer 0 can jump out of the loop, output n

CodePudding user response:

refer to 7th floor and pure ripple response:
use a for loop, then define a n, n is the number of a for loop, until the positive integer 0 can jump out of the loop, output n

Need positive output, can be in the loop, and an output

CodePudding user response:

Don't array, also need not converted to string methods:
 
#include

Int main ()
{
Long long x;
Int n=0;

Printf (" enter a number: ");
If (the scanf (" % LLD, & amp; X)!=1) puts (" bad input ");
The else
{
Printf (" % LLD is ", x!=0? X: (x=1, 0));
While (x)/x=10, n++;
Printf (" % d a number digit % s \ n ", n, n==1? "" :" s ");
}

return 0;
}

CodePudding user response:

The original topic is programming output of a number of positive output, then he edited,
  • Related