|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 weixianlang 于 2011-6-14 21:16 编辑
- #include <IOSTREAM.H>
- #include <STDIO.H>
- #include <STRING.H>
- #define N 3
- #define M 50
- void main()
- {
- char str[N][M];
- char (*p)[M],(*q)[M];
- p = q = str;
- int i,j;
- for (i=0; i<N; i++)
- {
- gets(q[i]);
- }
- if ( (strcmp (p[0] ,p[1] )) < 0 )
- {
- char *temp;
- temp = p[1];
- strcpy(p[1] , p[0]);
- strcpy(p[0] , temp);
- }
- if ( (strcmp (p[1] ,p[2] )) < 0 )
- {
- char *temp;
- temp = p[1];
- strcpy(p[1] , p[2]);
- strcpy(p[2] , temp);
- }
- if ( (strcmp (p[0] ,p[1] )) < 0 )
- {
- char *temp;
- temp = p[1];
- strcpy(p[1] , p[0]);
- strcpy(p[0] , temp);
- }
- for (i=0;i<N;i++)
- cout<<p[i]<<endl;
- }
复制代码 |
|