一、问题及代码
/*
* 文件名称:ff.cpp*
* 作 者:乐银芳
* 完成日期:2017 年 5月 10日
* 版 本 号:v1.0
* 对任务及求解方法的描述部分: 利用数组进行数据插入与重组
* 输入描述:数组变量
* 问题描述:第六次实验项目
* 程序输出:输出重组数组
* 问题分析:数据的插入与数组位置变化
* 算法设计:找到相应的位置,标记位置并插入
*/
#include <iostream>
using namespace std;
int main()
{
char c1[10]={"3598"},c2[3]={"ab"};
int i=0,j=0,len1=0,len2=0,index;
char max;
max=c1[0];index=0;
while(c1[i]!='\0')
{
if(c1[i]>max)
{
max=c1[i];index=i;
}
i++;
}
while(c1[len1]!='\0')len1++;
while(c2[len2]!='\0')len2++;
while(len1>len2)
{
c1[len1+len2]=c1[len1];
len1--;
}
index++;
while(c2[j]!='\0')
{
c1[index]=c2[j];index++;j++;
}
cout<<c1;
return 0;
}
二、运行结果
三、心得体会
字符数组有个重要结束标志要运用好,这个算法中要先找到最大数的位置,再进行数据的插入
四、知识点总结
字符数组的准确运用及结合前面所学的知识点技巧’