View Code of Problem 78

#include<stdio.h>
#include<string.h>
void main()
{
    char str[3][20];
    char str1[20];
    int i=0, j=0, min;
    for(i=0; i<3; i++)
    {
        //gets(p+i);
        scanf("%s", str[i]);
    }
    for(i=0; i<2; i++)
    {
        min = i;
        for(j=i+1; j<3; j++)
        {
            if(strcmp(str[j], str[min]) < 0)
                min = j;
        }
        if(min!=i)
        {
            strcpy(str1, str[i]);
            strcpy(str[i], str[min]);
            strcpy(str[min], str1);
        }
    }

    for(i=0; i<3; i++)
        printf("%s\n", str[i]);
}

Double click to view unformatted code.


Back to problem 78