Hi all
Here is my problem. I wrote a program that asks the user the input 10 different words. After the words are input, it then mirrors the words, as well as changes the upper/lower case and prints it out like the following for example.
Type word 1: Word
Type word 2: tEST
Type word 3: aGaIN
....... and so on until word 10
Unsorted Output
DROwwORD
tseTTest
niAgAAgAin
Now my problem is that I have to take the unsorted output, and sort it in ascending order.
Here is a snippet of my code posted here if someone could take a look at it, and see if they can come up with some help.
Anything is greatly appreciated.Code:#include <stdio.h> #include <string.h> int main(void) { char Word[10][19]; int i, j, k, l, z; int value; int str; char ch; for(z=0 ; z<10 ; z++) { if (z == 0) printf("Enter the 1st word: "); else if (z == 1) printf("Enter the 2nd word: "); else if (z == 2) printf("Enter the 3rd word: "); else printf("Enter the %dth word: ",z+1); i=0; while(( ch = fgetc(stdin)) != '\n') { i=i+1; Word[z][i]= ch; } l=10; for(k=i ; k>=1; k--) { Word[z][l]=Word[z][k]; l=l++; } Word[z][19]=i; } printf("\n"); printf("Unsorted Input: \n"); printf("\n"); for (z=0 ; z<10 ; z++) { for(j=10 ; j<=9+Word[z][19]; j++) { value = Word[z][j]; if (value >= 97 && value<=122) { value = value - 32; } else if (value >=67 && value<=90) { value = value + 32; } printf("%c", value); } for(j=1; j<=Word[z][19]; j++) { value = Word[z][j]; if (value >= 97 && value<=122) { value = value - 32; } else if (value >=67 && value<=90) { value = value + 32; } printf("%c", value); } putchar('\n'); } printf("\n"); printf("Sorted Input: \n"); printf("\n"); }



LinkBack URL
About LinkBacks



