欢迎来到天天文库
浏览记录
ID:58508757
大小:11.50 KB
页数:1页
时间:2020-09-03
《指针法实现输入3个字符串并按由小到大顺序输出.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、用指针法实现输入3个字符串,按由小到大顺序输出。#include"stdio.h"#include"string.h"intmain(){char*t;char*p1=NULL,*p2=NULL,*p3=NULL;charch1[20]={0},ch2[20]={0},ch3[20]={0};p1=ch1;p2=ch2;p3=ch3;printf("No1:");scanf("%s",p1);printf("No2:");scanf("%s",p2);printf("No3:");scanf("%s",p3);if(strcmp(p1,p2)>0){t=p1;p1=p2
2、;p2=t;}if(strcmp(p1,p3)>0){t=p1;p1=p3;p3=t;}if(strcmp(p2,p3)>0){t=p2;p2=p3;p3=t;}printf("%s%s%s",p1,p2,p3);return0;}
此文档下载收益归作者所有