Home > Net >  C # level 1 subject
C # level 1 subject

Time:09-24

Character array x in any string of characters; Please prepare the function, according to a given alternative relations to replace all the characters in the array x, is still in the array x position, finally calling function x output, the results
Substitution: f (p)=p * 11% 256 (p is an ASCII value of the characters in the array, f (p) is calculated after the new characters of ASCII value), if f (p) after calculation value is less than or equal to 32 or its ASCII value is even, the character is the same, otherwise will f (p) of the character to replace,

CodePudding user response:

Don't understand, or directly to the original problems?

CodePudding user response:

This topic out of the strange, why is dealt with less than 32, but does not handle more than 128 characters?

 
The static void Main (string [] args)
{
Char [] x={' a ', 'a', 'b', 'b', 'c', 'd', 'e', 'x', 'Y', 'Z', '9', '0'};

For (int I=0; I & lt; X.L ength; I++) {

Int v=f (x [I]);

if (! (v & lt;=32 | | v % 2==0)) {
[I]=x (char) v.
}

}

The foreach (char temp in x) {
The Console. Write (temp);
}

The Console. ReadLine ();
}

Static int f (int) p
{
The return p * 11% 256;
}
}

  •  Tags:  
  • C #
  • Related