Home > Back-end >  A novice for help
A novice for help

Time:09-22

Could you tell me how to do under this problem?
Assume that the input string contains only letters and *, please write the function fun, its function is to: except * at the end of the string leading and the string of other * all deleted, parameter h has pointed to the first letter of a string, parameter p has pointed to the last letter in the string, in writing functions, shall not use string functions provided by the C language,
For example, the contents of the string is: * * * * A * BC * DEF * G * * * * * * * *, after deleting the contents of the string should be: ABCDEFG * * * * * * * * * * * *, in writing functions, shall not use string functions provided by the C language, (25 points)
Subject content:

#include
#include
Void fun (char [] a)
{
//complete
}

The main ()
{char s [81], * t, * f;
Gets (s);
Fun (s);
Puts (s);

}



Input format:

* * * * A * BC * DEF * G * * * * * * * *



The output format:

ABCDEFG * * * * * * * * * * * *

CodePudding user response:

Can be a little bit more simple, loop through delete (mobile)

CodePudding user response:

Can be used for loop set if judgment in a row, after the current one character at a time not to * and a character not to * and this character to * delete this character
[I] if (s=='*' & amp; & S [I - 1)!='*' & amp; & S [I + 1)! )='*'

CodePudding user response:

While two Pointers to the first letter of the first and last letter
Then in the middle of the two Pointers judgment, have * skip, assign a value to a string variable, then add the corresponding *
  • Related