zzulioj 1017: Determine the number of positive integers

Title description
Given a positive integer with no more than 5 digits, determine how many digits it is, and output it.
Enter
a positive integer with no more than 5 digits.
Output The
number of digits of a positive integer, on a single line.
Sample input Copy
111
Sample output Copy
3
while:

#include<stdio.h>
int main()
{
    
    
	int n,x=0;
	scanf("%d",&n);
	while(n>=1)
	{
    
    
		x++;
		n=n/10;
	}
	printf("%d\n",x);
	return 0;
 } 

for:

#include<stdio.h>
int main()
{
    
    
	int i,n;
	scanf("%d",&n);
	for(i=0;n>=1;i++)
	   n=n/10;
	printf("%d",i);
	return 0;
}

Guess you like

Origin blog.csdn.net/m0_53024529/article/details/112706857