Title Description
Congratulations on entering the Blue Bridge Cup finals, this competition uses the automatic machine evaluation system.
If you have a gap between your answers and the standard answer, you may not be able to score, so be extra cautious!
But you don't have to be too alarmed. Because in some cases, the evaluation system will "blank format" your answer. This is done by removing all the blanks, and replacing the middle one with a single space. The so-called Blank refers to: space, tab, carriage return.
The following code implements this functionality. Read the code carefully, fill in the missing parts, and add the complete to make it work.
void f (char* from, char* to)
{
char* p_from = from;
char* p_to = to;
while (*p_from== ' | | | *p_from== ' \ t ' | | *p_from== ' \ n ') p_from++;
do{
if (*p_from== ' | | | *p_from== ' \ t ' | | *p_from== ' \ n ') {
do{p_from++;} while (*p_from== ' | | | *p_from== ' \ t ' | | *p_from== ' \ n ');
if (____________________) *p_to++ = "; Fill in the blanks
}
}while (*p_to++ = *p_from++);
}
Input
One line of code, not a standard format.
Output
The standard form of the output code.
Sample input
char* p_from = from ;
Sample output
char* p_from = from;
Tips
The standard format of the code is that there are no spaces at the end of the line, there should be only one space in the middle where there are no more.
Code
#include <iostream> #include <cstdio> using namespace std; void f (char* from, char* to) { char* p_from = from; char* p_to = to; while (*p_from== ' | | | *p_from== ' \ t ' | | *p_from== ' \ n ') p_from++; Do { if (*p_from== ' | | *p_from== ' \ t ' | | *p_from== ' \ n ') {do { p_from++; } while (*p_from== ' | | | *p_from== ' \ t ' | | *p_from== ' \ n '); if (*p_from!= ' &&*p_from!= ' \ t ' && *p_from!= ' \ n ') *p_to++ = '; } } while (*p_to++ = *p_from++); } int main () { char a[1000],b[1000]; while (gets (a)) { F (b); cout<<b<<endl; }
Some of the items-blank formatting