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PgEzOzRhjjPnpLH/gOX5h8oVi8nJR5evKyPLuhPPEWdgDfTs9VZqg8qkt8wP0kOVlvb3zDK/Av9JjjDHmHSx/2wvEL1fcr75Yqy/kKchfrQr4WBvXSSxXFtv5MqKm0tXTeL1/An7xMcYY8y6OfuBZU/hlzittkRhDMtuELi/6JjUQQ6a6FZP6Xb1JHcbsxq6g1iSWZPWZv+oNVC8+v379+ntnjDHGXMfyj7oD/YLVe8B9tGfwCzEyaOFfVPV27UB91T3oNJRVXlcDnNapqOK6/GlfK1tXQ+ELkF94jDHG3M3oB5478MU2/YIDiNOlQGeyrgR6096V015O60Woc9LDhGmPV8wC/NJjjDHmXYx+5QfwSzYL777QNS+L63I7TrQqP+wRxqlPc2mv6k01SdTp9OGLvVR9gMq/yovsxCMW7OgbY4wx72D8214AofELkHu1Mx5ksUpmmxDzpjqn9T4B9A6y/le+HXvFdz47Y4wxhox+4DmG8Eswfhl2X47Uqmja+B+ynrq6GbvxX002c8XO+fz0czPGGGMyxr/tZYwxxhjzE1j+wLMxxhhjzE/CLz/GGGOMeRR++THGGGPMo/DLjzHGGGMehV9+jDHGGPMo/PJjjDHGmAfxn//8P2Tdg9EnA895AAAAAElFTkSuQmCC" alt="" />

解决代码及点评


/*
有两个磁盘文件,各自存放已排好序的若干个字符(如a1. dat 中放"abort", a2.dat中放 "boy")
要求将两个文件合并,合并后仍保持有序,存放在a3.dat文件中。
提示:可先将两个文件中的字符存入一个字符型数组中,而后对数组重新排序,再将该数组写入a3.dat文件中。
如果不引入一个中间数组进行重新排序,该如何编程? */ #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h> #define SWAP(x,y) {char tmp; tmp = (x); (x)=(y); (y)=tmp;} static void str_sort(char *str, int str_size)
{
int i,j; for (i = 0; i < str_size; i++)
{
for (j = str_size - 2; j >= i; j--)
{
if (str[j] > str[j+1])
{
SWAP(str[j],str[j+1]);
}
}
}
} int main()
{
FILE *fp = NULL;
char str[128] = "";
char *p = str; fopen_s(&fp, "a1.dat", "r");//打开a1.dat
if (fp == NULL)
{
fopen_s(&fp, "a1.dat", "w+");//读写
fprintf(fp, "%s", "abort");
rewind(fp);
}
fscanf_s(fp, "%s", str);
fclose(fp); p = str+strlen(str);//p移动到末尾 fopen_s(&fp, "a2.dat", "r");//打开a2.dat
if (fp == NULL)
{
fopen_s(&fp, "a2.dat", "w+");//读写
fprintf(fp, "%s", "boy");
rewind(fp);
}
fscanf_s(fp, "%s", p);
fclose(fp); str_sort(str, strlen(str));//对str[]进行排序
printf("%s\n", str); fopen_s(&fp, "a3.dat", "w");//将str写入a3.dat
fprintf(fp, "%s", str);
fclose(fp); return 0;
}

代码编译以及运行

由于资源上传太多,资源频道经常被锁定无法上传资源,同学们可以打开VS2013自己创建工程,步骤如下:

1)新建工程

2)选择工程

3)创建完工程如下图:

4)增加文件,右键点击项目

5)在弹出菜单里做以下选择

6)添加文件

7)拷贝代码与运行

程序运行结果

代码下载

http://download.csdn.net/detail/yincheng01/6694119

解压密码:c.itcast.cn




基于visual Studio2013解决C语言竞赛题之0908文件合并的更多相关文章

  1. 基于visual Studio2013解决C语言竞赛题之0906文件插入

       题目

  2. 基于visual Studio2013解决C语言竞赛题之0905文件读写显示

       题目

  3. 基于visual Studio2013解决C语言竞赛题之0904文件排序

       题目

  4. 基于visual Studio2013解决C语言竞赛题之0903文件读写

       题目

  5. 基于visual Studio2013解决C语言竞赛题之0902文件查找

       题目

  6. 基于visual Studio2013解决C语言竞赛题之0901文件读写

       题目

  7. 基于visual Studio2013解决C语言竞赛题之0401阶乘

      题目 解决代码及点评 这个是一道经典的教科书题目,基本上每本基础的c/c++语言教科书都会有这个题目 用来演示循环语句 #include <stdio.h> #include ...

  8. 基于visual Studio2013解决C语言竞赛题之0205位数求和

     题目

  9. 基于visual Studio2013解决C语言竞赛题之0201温度转换

    题目 解决代码及点评 #include <stdio.h> #include <stdlib.h> void main() { float f; float c; float ...

随机推荐

  1. 关于UITableview刷新笔记

    今天在做项目的时候 发现调用tableview 的 reloaddata 方法的时候出现崩溃. - 具体操作是执行某个方法后将数据数组中的某条数据删除(数组中存数组)发现调用刷新方法后 程序崩溃,查看 ...

  2. 加特殊符号星号斜杠反斜杠/* \ */ !important等让css实现兼容各个浏览器的技巧的代码

       在编写css样式表的时候常常会碰到一写浏览器兼容的问题,象是不同内核的浏览器显示就不一定相同,不同版本的的浏览器也会产生上下兼容的问题,如何解决这些问题成了我们苦恼的问题,如果你对css hac ...

  3. jz2440不能成功地启动文件系统, Failed to execute /linuxrc.

    文件系统加载失败,错误信息提示:    VFS: Mounted root (nfs filesystem).    Freeing init memory: 140K    Failed to ex ...

  4. 5.对象创建型模式-原型PROTOTYPE

    原型:用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象. 原型实现:1.用于创建对象的具体类必须实现clone()操作,用于对象克隆自己以生成新的对象.下面通过原型来实现一个抽象工厂Ma ...

  5. Java大顶和小顶

    http://blog.sina.com.cn/s/blog_651c9a360100o7y1.html http://blog.csdn.net/cnbird2008/article/details ...

  6. linux基础随笔

    磁盘管理 sda s:磁盘接口的类型(sata scsci sas) d:驱动器(drive) a:(第一块磁盘,同理b第二块磁盘)hda h:ide接口 第一块磁盘的第一个分区:sda1 mount ...

  7. commons-logging和slf4j都是日志的接口

    过上面的图,可以简单的理清关系! commons-logging和slf4j都是日志的接口,供用户使用,而没有提供实现! log4j,logback等等才是日志的真正实现. 当我们调用接口时,接口的工 ...

  8. 第四种:GCD

    GCD 1> 概述 Grand Central Dispatch (GCD)是Apple开发的一种多核编程技术.主要用于优化应用程序以支持多核处理器以及其他对称多处理系统. GCD提供函数实现多 ...

  9. 王立平--android事件监听的3种方式

    第一种通常在activity组件的oncreate事件中直接定义,直接动作. 这样的方式每一个控件都定义一次.通常不方便. Button btn = (Button) findViewById(R.i ...

  10. 2013 ACM/ICPC Asia Regional Chengdu Online---1003

    哈哈哈 #include <iostream> #include <cstring> #include <string> #include <cstdio&g ...