Home > Back-end >  For help! Play a few hours of code were found to have not to come out
For help! Play a few hours of code were found to have not to come out

Time:01-04

Put the string into an integer, and calculate how many number
Using the write function change (char * s, int * p)

CodePudding user response:

Reference:
 # include & lt; Iostream. H> 
#include
Int change (char * s, int * p)
{
Int j, n=0, I, k;
Char \ [100].
for (i=0; S [I]!='\ 0'; I++)
{
J=0;
k=0;
[I] while (s & gt;='0' & amp; & S [I] <='9')
{
If (k==0 & amp; & i!=0 & amp; & S [I - 1]=='-')//negative processing
{
[j]=s \ [I - 1);
j++;
k++;
}
Temp [j] [I]=s;
j++;
i++;
}
If (j!=0)
{
Temp [j]='\ 0';
* p=atoi (temp);
p++;
n++;
I -;
}

}
Return n.
}



Int main (int arg c, char * argv [])
{
Char ss [100].
Int n, a, [100].
Gets (ss);
N=change (ss, a);
Cout<& lt;" N="& lt;

return 0;
}
  • Related