Home > Back-end >  Why can't a main function recursive after inputting information?
Why can't a main function recursive after inputting information?

Time:10-11

#include
#include
#include//to dynamically allocated memory function of header files and exit (0) function such as header files,
#include
using namespace std;

Int main ()
{
Int printf1 (void);
Printf1 ();//display program is introduced first,
Cout<& lt;" Both please input a string: ";
Char s [1000];
Gets (s);//cin> s;
Int I=0, i1=0, i2=0, i3=0, num [100], digit [100].
Bool flag=0;
for(i=0; i<=strlen (s); I++)//traversal string, strlen () to get the effective length of the string
{
If (s [I] & gt;='0' & amp; & S [I] <='9')//is digital
{
Flag=1;
Digit (i1)=s [I] - 48;//digital character string into a numerical,
I1 + +;
}//array stored in consecutive digit/i1 and digit [i1] is null, the flag=1 the number has been found,
Else if (flag==1)//not digital and the former one has found,
{
Int I=0, sum=0, frequency=0;
For (I=i1-1; i>=0; I -)
{
The sum +=digit [I] * pow (10, frequency);
I1 + +;
Frequency++;
Digit [I]=NULL;//digit initialization,
}//digit figures in continuous i1 is converted to a decimal value sum,
Num (i3)=sum;
I3 + +;//i3 integer, from 0 (i3) stored in the num] [i3-1,
Flag=0;
I1=0;
}
Else if (flag==0)
{
continue;
}
}
Cout<& lt;" This string include "& lt; Cout<& lt;" Those are: "& lt; for(i=0; i<=i3-1; I++)
{
Cout<& lt;" Number "& lt; }
Cout<& lt;"====if you want to exit programmar? Both please input yes or no.===="& lt; Char option [4];//c style string is best stored null, keep a position when the input string length is greater than the allocated space, the system will automatically expand the space,
While (1)
{
The scanf (" % s ", option);
If (STRCMP (option, "yes")==0 | | STRCMP (option, "no")==0)
{
break;
}
The else
{
Cout<& lt;"====inputed option mistake! Both please input right option!===="& lt; }
}//that the input options right,
The switch (STRCMP (option, "yes"))
{
Case: 0 exit (0); break;
Default: the main ();//when all don't meet the case when the default statement,
}
}
Int printf1 (void)//parameter is void said no parameters,
{
Cout<& lt;"==welcome to this programmar informs the to depart the math number bettwen the string===="& lt; }
  • Related