Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5.  
  6. int main(void) {
  7.  
  8.     //declaration
  9.     int i, j, count;
  10.     char str[25][25], temp[25];
  11.  
  12.     //Questions
  13.     puts("How many strings u are going to enter?: ");
  14.     scanf_s("%d", &count);
  15.  
  16.     puts("Enter Strings one by one: ");
  17.     for (i = 0;i <= count;i++) {
  18.         gets(str[i]);
  19.     }
  20.  
  21.     //Sorting strings
  22.     for (i = 0;i <= count;i++)
  23.         for (j = i + 1;j <= count;j++) {
  24.             if (strcmp(str[i], str[j])>0) {
  25.                 strcpy(temp, str[i]);
  26.                 strcpy(str[i], str[j]);
  27.                 strcpy(str[j], temp);
  28.             }
  29.         }
  30.  
  31.     //Printing
  32.     printf("Order of Sorted Strings:");
  33.     for (i = 0;i <= count;i++) {
  34.         puts(str[i]);
  35.     }
  36.  
  37.     system("pause");
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement