升序排列字符数组
2016-04-13 10:30
197 查看
问题及代码:
/*
*Copyright (c)2015,大连东软信息学院
*All rights reserved.
*文件名称:10 16 8.c
*作 者:陈振
*完成日期:2016年4月13日
*版 本 号: v1.0
*问题描述: 从键盘输入两个字符串(两行),分别存入两个字符数组c1,c2中,比较它们的大小,并且对二者进行升序排列(小的放入c1,大的放入c2),然后把c1和c2在两行中分别打印出来
*程序输入:
*程序输出:
*/
#include <stdio.h>
#include <string.h>
int main()
{
char c1[30];
char c2[30];
char c3[30];
gets(c1);
gets(c2);
if(strcmp(c1,c2)<0){
puts(c1);
puts(c2);
}
else{
strcpy(c3,c1);
strcpy(c1,c2);
strcpy(c2,c3);
puts(c1);
puts(c2);
}
return 0;
}运行结果:
/*
*Copyright (c)2015,大连东软信息学院
*All rights reserved.
*文件名称:10 16 8.c
*作 者:陈振
*完成日期:2016年4月13日
*版 本 号: v1.0
*问题描述: 从键盘输入两个字符串(两行),分别存入两个字符数组c1,c2中,比较它们的大小,并且对二者进行升序排列(小的放入c1,大的放入c2),然后把c1和c2在两行中分别打印出来
*程序输入:
*程序输出:
*/
#include <stdio.h>
#include <string.h>
int main()
{
char c1[30];
char c2[30];
char c3[30];
gets(c1);
gets(c2);
if(strcmp(c1,c2)<0){
puts(c1);
puts(c2);
}
else{
strcpy(c3,c1);
strcpy(c1,c2);
strcpy(c2,c3);
puts(c1);
puts(c2);
}
return 0;
}运行结果:
相关文章推荐
- Apache Lucene初探
- swift map filter reduce函数
- Android Studio 运行项目出现Information:Gradle tasks异常解决办法。
- __attribute__ 你知多少?
- leetcode - roman to integer & integer to roman
- iOS自定义弹出框
- IPC(四)_Aidl的基本使用过程
- python小模块---fileinput
- 程序员应该接外包吗?
- MVP架构
- Linux kernel内核架构的理解
- phpstudy 安装memcached服务和memcache扩展
- 【Android Studio错误】 If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.
- 关于AppStore上线遇到900034证书问题 !已解决
- axure RP 7.0 预览空白页面,无法预览
- 《商业模式创新》--温明
- Getting Started with 'nanomsg'
- Eclipse数据监听工具TCP/IP Monitor
- Redis命令-有序集合-zrangebylex
- linux iptables ip_conntrack: table full CentOS 7 iptables