#include <stdio.h> #include <string.h> int main() { int i,a,cd; char num[]={0}; char num1[]={0}; //put into the array Input data scanf ("%s",num); //Using the string length detection function to measure the length cd=strlen (num); printf ("It is a %d digit\n",cd); //Using FOR loop to output the array value, here do not directly use the Printf function to output the array value, otherwise it will affect the result for (i=0;i<cd;i++) { printf ("%c ",num[i]); } printf ("\n"); //Use the FOR loop to exchange array values, and then use the FOR loop to output. for (i=0,a=cd-1;i<cd;i++,a--) { num1[a]=num[i]; } for (i=0;i<cd;i++) { printf ("%c",num1[i]); } printf ("\n"); return 0; }
For a positive integer with no more than 5 digits, the requirements: 1. Find out how many digits it is; 2. Output each digit separately ------
Guess you like
Origin blog.51cto.com/15144773/2675627
Recommended
Ranking