Advertisement
Utkar5hM

Untitled

Mar 4th, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main() {
  4.     int n;
  5.     printf("enter size of string array:");
  6.     scanf("%d",&n);
  7.     char x[n][999];//unordered string
  8.     for(int i=0; i<=n;++i){
  9.         scanf("%s",&x[i][999]);
  10.         printf("%d%s",i,x[i]);
  11.     }
  12.     char temp[999];
  13.     for (int j=0; j<n-1; j++) {
  14.         for (int k=j+1; k<n; k++) {
  15.             if (strcmp(x[j], x[k]) > 0) {
  16.                 strcpy(temp, x[j]);
  17.                 strcpy(x[j], x[k]);
  18.                 strcpy(x[k], temp);
  19.             }
  20.         }
  21.     }
  22.     printf("\nOrdered %d string array elements:\n", n);
  23.     for(int m=0; m<n;++m){
  24.         printf("%s\n", x[m]);
  25.     }
  26.  
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement