Created
March 17, 2015 10:48
-
-
Save tomcha/40f41f2e526a5ce6c753 to your computer and use it in GitHub Desktop.
1-19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define MAXCHAR 100 | |
| void reversd(int i, char s[], char r[]); | |
| void cleararray(char array[]); | |
| int main(){ | |
| char s[MAXCHAR]; | |
| char r[MAXCHAR]; | |
| int c; | |
| int i = 0; | |
| while((c = getchar()) != EOF){ | |
| if(c != '\n'){ | |
| s[i] = c; | |
| i++; | |
| }else{ | |
| reversd(i, s, r); | |
| printf("%s\n", r); | |
| i = 0; | |
| cleararray(s); | |
| cleararray(r); | |
| } | |
| } | |
| } | |
| void reversd(int i, char s[], char r[]){ | |
| i--; | |
| int j; | |
| for(j = 0; i >= 0; j++){ | |
| r[j] = s[i]; | |
| i--; | |
| } | |
| } | |
| void cleararray(char array[]){ | |
| for(int i = 0; i < MAXCHAR; i++){ | |
| array[i] = '\0'; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment