Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- //------------------------------------------------------------------------------
- // ass-b1.c
- //
- // Ein Programm das Namen Rückwärts ausgibt, dabei die Anfangsbuchstaben gegen Großbuchstaben
- // und die Großbuchstaben am Ende gegen Kleinbuchstaben ersetzt.
- //
- // Group: Group 16, study assistant
- //
- // Authors: Ernst Kicker 11803389
- //------------------------------------------------------------------------------
- //
- int reversePrint(char *name);
- int reversePrint(char *name)
- {
- int x, y, t, m, s, space, wert; // index Variablen
- wert = 0;
- if(name[0] == '\0')
- {
- wert = -1;
- }
- space = 0;
- for(s = 0; name[s] != '\0'; s++)
- {
- if(isspace(name[s]) != 0)
- {
- if(isgraph(name[s+1]) != 0)
- {
- space += 1;
- printf("%i \n", space);
- }
- }
- }
- if(space == 0)
- {
- wert = -2;
- }
- for(m = 0; name[m] != '\0'; ++m)
- {
- if(isupper(name[m]) != 0)
- {
- name[m] = tolower(name[m]);
- }
- }
- char test_teiler[m];
- char neu[m];
- x = 0;
- for(t = 0; t <= m; t++)
- {
- if(isgraph(name[t]) != 0)
- {
- test_teiler[t] = name[t];
- }
- else
- {
- for(y = t-1; x <= t-1; x++, y--)
- {
- neu[x] = test_teiler[y];
- }
- test_teiler[t] = name[t];
- neu[t] = name[t];
- neu[y+1] = toupper(neu[y+1]);
- x += 1;
- }
- }
- if(space > 0)
- {
- printf("%s \n", neu);
- }
- return wert;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement