c - problem getting my program to work -
I am having a newbie problem with my program ....
I want it Print both a list of cities in ascending and descending order, so far I am only implementing the falling part.
# include & lt; Stdio.h & gt; #to & lt include, stdlib.h & gt; #to & lt include, string.h & gt; # Include & lt; Ctype.h & gt; Int main (zero) {int i, j, ch, sort = 0; Printf ("How would you like to dry? \ N \ n Working \ n \ n Desigending \ n \ n"); Ch = getc (stdin); If (tuper (ca) == 'a' and 'tolar (ca) ==' a ') sort = 1; If (sort == 1) printf ("\ nSupport Assending ... \ n"); Else printf ("\ nSupporting ... \ n"); Printf ("How many cities do you want ?: - \ n"); Scanf ("% d", & amp; i); Four names [i] [20]; J = 0; While (J & lt; i) {printf ("ENTER NAME"); Scanf ("% s", name [ja]); J ++; } Four Swapnames [20]; Int r, k; Printf ("The original list was: \ n"); For (R = 0; R & lt; i; R ++) printf ("% s \ n", NAMES [r]); (For (R = 0; R & lt; i-1; r ++) {for (= R + 1; k & lt; i; k ++) {if (SRCMP (NAMES [K] NAMES [r] gt 1) {strcpy (swapNAME, name [r]); strcpy (name [r], name [k]); strcpy (name [k], swapNAME);}}} Printf ("\ n" The sorted list is now: \ n "); for (R = 0; R & lt; i; R ++) printf ("% s \ n ", NAMES [r]); getc (stdin); system (" Pause "); return 0;} Any attempt is greatly appreciated Aginin thankz
If the descending type is working, then you need to get all the If statement is for handling other directions: for (r = 0; r 0 ) (Sort == 1 & amp; ARCPM (Name S [K], NAMES [R]) <)) {Strakpy (Swapamy, NAMES [R]); strcpy (name [R], name [K]); strcpy (name [k], swapNAME);}}}
Comments
Post a Comment