1 #include<stdio.h> 2 3 int main(void) 4 { 5 int x; 6 int n = 0; 7 8 scanf_s("%d", &x); 9 10 x = x / 10; 11 n++; 12 13 while (x > 0) 14 { 15 x = x / 10; 16 n++; 17 } 18 19 printf("%d ", n); 20 21 return 0; 22 }
1 #include<stdio.h> 2 3 int main(void) 4 { 5 int x; 6 int n = 0; 7 8 scanf_s("%d", &x); 9 10 do 11 { 12 x = x / 10; 13 n++; 14 } while (x > 0); 15 16 printf("%d ", n); 17 18 return 0; 19 }
1 #include<stdio.h> 2 3 int main(void) 4 { 5 int x, y =1; 6 int n = 0; 7 8 scanf_s("%d", &x); 9 10 do 11 { 12 x = x / 10; 13 n++; 14 } while (x != 0); //不等于0,继续循环 15 16 printf("%d ", n); 17 18 return 0; 19 }