Osoittimet¶
Palindrome (2p)¶
Write a function that checks whether a given string is a palindrome. The function returns
0
, if the string is a palindrome. The function returns n
, if it is not a palindrome. n
is the order number of the letter that "breaks" palindrome, counted from left. Example.
A string "huhhuh" returns 0 A string "huhhoh" returns 2
Use function prototype
uint8_t palidromi(char *s, uint8_t length);
, where s
is the string and length
is it's length. Hint. You can use string library function
strlen
to get the string length.
Vihjeet
Viestit
Hexspeak (2p)¶
Write a function that converts individual characters of a given string into hexspeak and prints out the modified string.
The conversion rules are the following:
- Characters 'o' ja 'O' -> '0' (zero)
- Characters 'l' ja 'L' -> '1'
- Characters 's' ja 'S' -> '5'
- Characters 't' ja 'T' -> '7'
- Characters 'r' ja 'R' -> '12' (two numbers)
- Character 'G' -> '6'
- Character 'g' -> '9'
- All other characters as they are
Use function prototype
int hexspeak(char *str, int len);
. The function returns the number of changed characters in the original string. Hint. It could be a good idea to use switch-case clause here.
Vihjeet
Viestit
Anna palautetta
Koitko tämän tehtävän hyödylliseksi oppimisen kannalta?
Kommentteja tehtävästä?
Tekstipalaute¶
Huom, tämä laatikko on vain palautetta varten. Mikäli haluat esittää tehtäviin liittyviä kysymyksiä, ne kannattaa suunnata Slack-kanavalle, esittää assareille harjoituksissa tai kurssin sähköpostiin (computer-systems@ee.oulu.fi).
Käsittelemme palautteita luennoilla sekä tarpeen mukaan vastaamme niihin vastaussivulla.
Voit lähettää niin monta palauteviestiä kuin keksit aiheita!
Vihjeet
Viestit
Anna palautetta
Kommentteja tehtävästä?