Home > Back-end >  Something wrong with the OJ2910 extract Numbers (ah)
Something wrong with the OJ2910 extract Numbers (ah)

Time:06-10

#include
#include
Int main ()
{
Char a, [109].
Int x [109];
Gets (a);
Int len=strlen (a);
Int I, t=0, j, k, y=0;
For (I=0; i {
If (a [I] & gt;=49 & amp; & A [I] <=57)
{
For (j=I; A [j] & gt;=48 & amp; & A [j] <=57; J++)
{
X=[t] a [j] - 48;
t++;
}
I=j;
If (y & gt; 0)
{
For (k=y + 1; K & lt; t; K++)
{
Printf (" % d ", x [k]);
Y=k;
}
}
Else if (y==0)
{
For (k=0; K & lt; t; K++)
{
Printf (" % d ", x [k]);
Y=k;
}
}
printf("\n");
}
Else if (a==[I] 48 & amp; & (a + 1] [I & gt; 57 | | a [I + 1] <48))
{
Printf (" % c \ n ", a [I]);
}
}
return 0;
}

CodePudding user response:

What's the problem?

CodePudding user response:

Directly on the VJ WA changed many times

CodePudding user response:

I think you can put the topic posted, the only answer who understand what do you want to do

CodePudding user response:

This code do not have what problem, you can run on VS, the result is right,,,

CodePudding user response:

 # include 
#include

Int main ()
{
Char a, [109].
Int x [109];

Gets (a);
Int len=strlen (a);
Int I, t=0, j, k, y=0;
For (I=0; i {
If (a [I] & gt;='1' & amp; & A [I] <='9') {
X=[t++] a [I] - '0';
continue;
}
Printf (" % c ", a [I]);
/*
If (a [I] & gt;=49 & amp; & A [I] <=57)
{
For (j=I; A [j] & gt;=48 & amp; & A [j] <=57; J++)
{
X=[t] a [j] - 48;
t++;
}
//I=j;//here will change the outer loop
If (y & gt; 0)
{
For (k=y + 1; K & lt; t; K++)
{
Printf (" % d ", x [k]);
Y=k;
}
}
Else if (y==0)
{
For (k=0; K & lt; t; K++)
{
Printf (" % d ", x [k]);
Y=k;
}
}
printf("\n");
}
Else if (a==[I] 48 & amp; & (a + 1] [I & gt; 57 | | a [I + 1] <48))
{
Printf (" % c \ n ", a [I]);
}
*/
}
Putchar (10);
For (I=0; i Printf (" % d ", x [I]);
Putchar (10);

return 0;
}

For your reference ~

Extract the number, don't consider too complicated,

CodePudding user response:

 # include 
#include

Int main ()
{
Char a, [128].
Int x [128];
Int len.
Int I, t=0;

Gets (a);
Len=strlen (a);

For (I=0; i {
If (a [I] & gt;='0' & amp; & A [I] <='9') {
X=[t++] a [I] - '0';
continue;
}
Printf (" % c ", a [I]);
}
Putchar (10);
For (I=0; i Printf (" % d ", x [I]);
Putchar (10);

return 0;
}

After optimization, for your reference ~ 0 is also in the category of digital

CodePudding user response:


I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related