블로그 이미지
송시혁

calendar

1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

Notice

Tag

Recent Post

Recent Comment

Recent Trackback

Archive







#include <stdio.h>
#include <string.h>
#define MAXSTD 10
#define NAMELEN 15
int main()
{
    char student[MAXSTD][NAMELEN];
    char *stptr[MAXSTD];
    char *temp;
    
    int i, j, count =0;
         
    printf("Please enter name of student :\n");
    while(count < MAXSTD)
    {
      printf("Student %d : ", count +1);
      gets(student[count]);
    stptr[count]= student[count];
    count = count +1;
    }

    for(i= 0; i< count -1; i++)
    {
      for(j=i +1;j<count; j++)
      {
        if(strcmp (stptr[i], stptr[j]) >0)
        {
          temp = stptr[j];
          stptr[j]= stptr[i];
          stptr[i]=temp;
        }
      }
    }
    printf("\nStudent List : \n");
    for(i = 0; i< count; i++)  
    {
      printf("Student %d: %s\n", i +1, stptr[i]);
    }
  return 0;
}

posted by 송시혁