Advertisement
aunkang

Lab9-2

Jan 23rd, 2014
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.50 KB | None | 0 0
  1. #include <stdio.h>
  2.  int main()
  3. {
  4.      int i=0,j=0,k,l,len=0,count=0;
  5.      int lenTemp[10],temp;
  6.     char names[100][11];
  7.     char input[20];
  8.     char tempChar[11],tempChar2[11];
  9.     for(i=0;i<=9;i++)
  10.     {
  11.        scanf("%s",input);
  12.        len = 0;
  13.        while(input[len]!='\0')
  14.        {
  15.          len += 1;
  16.        }
  17.        lenTemp[i] = len;
  18.        for(j=0;j<=len-1;j++){
  19.           names[j][i] = input[j];          
  20.        }
  21.        names[j+1][i] = ':';
  22.     }
  23.     for(i=0;i<=9;i++)
  24.     {
  25.         tempChar[i] = names[0][i];
  26.         tempChar2[i] = names[1][i];
  27.     }
  28.     for(i=0;i<=8;i++)
  29.     {
  30.         for(j=0;j<=8;j++)
  31.         {
  32.             if(tempChar[j]>tempChar[j+1])
  33.             {  
  34.                 temp = tempChar[j];
  35.                 tempChar[j] = tempChar[j+1];
  36.                 tempChar[j+1] = temp;
  37.                
  38.                 temp = tempChar2[j];
  39.                 tempChar2[j] = tempChar2[j+1];
  40.                 tempChar2[j+1] = temp;
  41.             }
  42.         }
  43.     }
  44.     for(i=0;i<=9;i++){
  45.         for(j=0;j<=9;j++){
  46.             if(names[0][j] == tempChar[i]){
  47.                 while(count<=lenTemp[j]-1)
  48.                 {          
  49.                     printf("%c",names[count][j]);
  50.                     count += 1;
  51.                 }
  52.                 count = 0;
  53.                 printf("%c%d\n",':',j+1);
  54.             }
  55.         }
  56.     }
  57.    
  58.     printf("\n");
  59.     printf("Message : ");
  60.     for(i=0;i<=9;i++) printf("%c",tempChar2[i]);
  61.     system("PAUSE");
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement