• NYOJ 283


     1 #include <cstdio>
     2 #include <cstdlib>
     3 #include <iostream>
     4 #include <cstring>
     5 #include <algorithm>
     6 #include <string>
     7 using namespace std;
     8 /*
     9 bool cmp(char *a,char *b)
    10 {
    11      int len1 = strlen(a);
    12      int len2 = strlen(b);
    13      return len1>len2;
    14 }
    15 */
    16 int cmp(const void *a,const void *b)
    17 {
    18      int len1 = strlen((char *)a);
    19      int len2 = strlen((char *)b);
    20      return len1>len2;
    21 }
    22      
    23 int main()
    24 {
    25      char str[16][25];
    26      int i,j,k=1;
    27      int  num;
    28      while(scanf("%d",&num),num)
    29      {
    30           memset(str, 0, sizeof(str)); 
    31           for(i=0;i<num;i++)
    32                cin>>str[i];
    33           //sort(str,str+num,cmp);
    34           qsort(str,num,25,cmp);
    35           printf("SET %d\n",k);
    36           k++;
    37           for(i=0;i<num;i+=2)
    38                cout<<str[i]<<endl;
    39           for(j=num-1-num%2;j>0;j-=2) 
    40                cout<<str[j]<<endl;
    41      }
    42      //while(1);
    43      return 0;
    44 }
  • 相关阅读:
    13-Smell味道-调味料
    12-Juice饮料
    11-Snack小吃
    10-Meat肉类
    09-Fruit水果
    08-Vegetables蔬菜
    [svc]共享内存
    [sql]sql的select字符串切割
    [js] 渲染树构建、布局及绘制
    [js]变量提升-关于条件
  • 原文地址:https://www.cnblogs.com/hxsyl/p/2686012.html
Copyright © 2020-2023  润新知