#include <stdio.h> #include <stdlib.h> void swap(char *ap,char *bp); void compare(char *ap,char *bp); int main() { int b,c,y; int i=0; char info[13][20]= { "christina", "victor", "chris", "chester", "elta", "kezia", "bew", "grace", "mavis", "tony", "oat", "adonique", "ploy" }; char *ap; ap=info[i]; char *bp; bp=info[i+1]; for(i=0; i<13; i++) { printf("k"); compare(ap,bp); i++; } for(y=0; y<13; y++) { printf("k"); printf("%s\n",info[y]); } return 0; } void compare(char *ap,char *bp) { printf("k"); int x; int j=0; int damn; if(*ap==*bp) { while (*(ap+j)==*(bp+j)) { if (*(ap+j) == '\0' || *(bp+j) == '\0') { break; } } if (*(ap+j)<*(bp+j) || *ap<*bp) { damn=1; } if (*(ap+j)>*(bp+j)||*ap>*bp) { while(*(ap+j) != '\0' || *(bp+j) != '\0') { swap(ap,bp); j++; } } } } void swap(char *ap,char *bp) { int c; char tmp[20]; for(c=0; c<19; c++) { printf("k"); *tmp=*ap; *ap=*bp; *bp=*tmp; } }
for(i=0; i<13; i++) { printf("k"); compare(ap,bp); i++; }
char *ap; ap=info[i]; char *bp; bp=info[i+1]; for(i=0; i<13; i++) { printf("k"); compare(ap,bp); i++; }
ap
bp
int compare( const char * sl, const char * sr) { //implementation left to the OP } void sort( const char * info[], int items) { // implementation left to the OP // uses the compare and swap functions }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)