楼上的哥们可能没搞懂题意。。。 
我随便写了写下面是代码,虽然方法有点勉强,不过还算得出答案了 
- //
 
 - //  main.c
 
 - //  一道无聊的题 
 
 - //
 
 - //  Created by sniper-yj on 14-5-22.
 
 - //  Copyright (c) 2014 itcast. All rights reserved.
 
 - //
 
  
- #include <stdio.h>
 
 - #include <string.h>
 
  
- char a[]={"select * from (select * from heima1,(select c, d from  temp1 t1,(select g from   heima1 h1,temp1 t where g=1) t2 where t1.a=t2.b and t1 in (select f from itcast  )))"};
 
 - char b[10][10];
 
  
- int main()
 
 - {
 
 -     int n = 0,i,j,x,y;
 
 -     for (i = 0; i < strlen(a); i++)
 
 -     {
 
 -         if(a[i] == 'm'&&a[i+1] == ' '&&a[i+2]!='(')
 
 -         {
 
 -             int m = 0;
 
 -             for (j = i+2; j < strlen(a); j++)
 
 -             {
 
 -                 if(a[j]!=' ')
 
 -                 {
 
 -                     b[n][m++] = a[j];
 
 -                     if(a[j+1]==' '||a[j+1]==',')
 
 -                     {
 
 -                         break;
 
 -                     }           
 
 -                 }
 
 -                 
 
 -             }
 
 -             n++;              
 
 -         }
 
 -     }
 
 -     for (x = 0; x < n; x++)
 
 -     {
 
 -         printf("%s\n",b[x]);
 
 -     }
 
 -     return 0;
 
 - }
 
  复制代码 
 
最后我的输出结果是 
heima1 
temp1 
heima1 
itcast 
因为算出这部这道题基本没问题了,只需要对输出的值进行判断对首字母进行排序就可得出楼主的答案了,不过实在是不想写了,还要看oc视频呢。再给楼主一个建议,既然要学习oc就不用去专这些没用的题,因为oc不可能会用到这些知识,还是好好看看面向对象思想还有什么foundatation框架之类的才会更有好处。 |