codice:#include <stdio.h> #include <string.h> int main() { int i, j, x; char tmp[15]; char s[4][15] = { "ciao", "aiuto", "tutti", "dimmi come va?" }; int n =4; printf("Prima:\n\n"); for(x = 0; x < 4; x++) { printf("%s\n", s[x]); } for (i=0; i<n-1; i++) { for (j=0; j<n-1-i; j++) { if (strcmp(s[j+1], s[j]) < 0) { strcpy(tmp, s[j]); strcpy(s[j], s[j+1]); strcpy(s[j+1], tmp); } } } printf("\n\nDopo:\n\n"); for(x = 0; x < 4; x++) { printf("%s\n", s[x]); } }![]()

Rispondi quotando