View Code of Problem 78

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

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

Double click to view unformatted code.


Back to problem 78