Home > Back-end >  Bosses genuflect is begged to see where is wrong
Bosses genuflect is begged to see where is wrong

Time:06-10

#include
Int main () {
Int r;
The scanf (" % d ", & amp; R);
Float s [r];
Float * p=s;
Char x [r];
Char * c=x;
for(int i=0; iThe scanf (" % % f "c, c + +, p++);
}
P=s;
C=x;
for(int i=0; iIf (* c=='F') {
Printf (" \ n % 1.2 f ", * p * 1.09);
}
The else {
Printf (" \ n % 1.2 f ", * p/1.09);
}
}
return 0;
}
Read the along while don't know how to give an issue, from the operation result should be a problem with my input,

CodePudding user response:

The scanf in c + + p++, why write so much? Due to excessive confidence?

CodePudding user response:

Can run?
Compilation is wrong!
Float s [r];
The C language definition to specify an array length, need to use a constant here, can't use r
Char x [r]; It's the same,

CodePudding user response:

These two + + on the for the inside, bad i++ right?

CodePudding user response:

First of all, I if you use the dve I suggest you to install the stdio or query let dve debugging method, it is ok to debug,

CodePudding user response:

The scanf (" % d ", & amp; R);
getchar();


The scanf (" % % f "c, c + +, p++);
getchar();

Both the scanf followed by getchar (); To filter out the enter

CodePudding user response:

 # include 
#include

Int main ()
{
Int r;
The scanf (" % d ", & amp; R);
//float s [r].
Float * s;
//char x [r].
Char * x;
S=(float *) malloc (sizeof (float) * r);
if (! S)
exit(0);
X=(char *) malloc (sizeof (char) * r);
if (! X)
exit(0);

Char * c=x;
Float * p=s;

getchar();//for '\ n'
for(int i=0; i//the scanf (" % % f "c, c + +, p++);
The scanf (" % % f "c, c + I, p + I);
getchar();//for '\ n'
}
P=s;
C=x;
for(int i=0; iIf (* c=='F') {
Printf (" \ n % 1.2 f ", * p * 1.09);
}
The else {
Printf (" \ n % 1.2 f ", * p/1.09);
}
}

Free (s);
Free (x);

return 0;
}


For your reference ~

CodePudding user response:

refer to the second floor fireyou response:
can run?
Compilation is wrong!
Float s [r];
The C language definition to specify an array length, need to use a constant here, can't use r
Char x [r]; Here,

Is to be able to run, but the result is wrong, but I was in the pta on another topic, so, passed, and this is why,,

CodePudding user response:

, not the book wrote this, I just want to try,,,

CodePudding user response:

reference 5 floor not smell out the window of the reply:
the scanf (" % d ", & amp; R);
getchar();


The scanf (" % % f "c, c + +, p++);
getchar();

Both the scanf followed by getchar (); To filter out the enter

! Ok but why, I still don't understand

CodePudding user response:

That don't understand? Or don't understand?
Man is not to write clear, filter press enter,

CodePudding user response:

C99 supports VLA, float s [r]. Can be

CodePudding user response:

If not filter will be below the scanf receiving

CodePudding user response:

refer to the second floor fireyou response:
can run?
Compilation is wrong!
Float s [r];
The C language definition to specify an array length, need to use a constant here, can't use r
Char x [r]; Here,

What he means is a dynamic array, also like to write so when I was a student,
Using malloc/free
P=(... ) the malloc (sizeof (... ) * r)
Free (p)

CodePudding user response:

You use this PTA APP name?
I search for the PTA, no!

CodePudding user response:

refer to 12 floor qq_30821735 reply:
if not is it will be below the scanf receiving filter press enter

Yes.

CodePudding user response:

On the 14th floor proorck2019
reference response:
the PTA what is the name of the APP that you use?
I search for the PTA, no!

Pta is site, baidu once you know

CodePudding user response:

15 floor not smell out the window of the reference response:
Quote: refer to 12 floor qq_30821735 reply:

If not is it will be below the scanf receiving filter press enter

Yes

Using multiple the scanf is to pay attention to this point

CodePudding user response:

refer to 17th floor qq_30821735 response:
Quote: reference 15 floor not smell out the window of the reply:
Quote: refer to 12 floor qq_30821735 reply:

If not is it will be below the scanf receiving filter press enter

Yes

Using multiple the scanf is to pay attention to this point?

Yes, it is best not to continuous use the scanf, continuous use must pay attention to

CodePudding user response:

don't smell out of the window and references to the 18th floor response:
Quote: refer to 17th floor qq_30821735 response:

Quote: 15 reference floor not smell out the window of the reply:
Quote: refer to 12 floor qq_30821735 reply:

If not is it will be below the scanf receiving filter press enter

Yes

Using multiple the scanf is to pay attention to this point?

Yes, it is best not to use the scanf continuously, continuous use will note

Well I remember the thank you thank younullnullnullnull
  • Related