问题及代码:
/*Copyright(c)2016,烟台大学计算机学院 all rights reserved.
作者:曹欣宇
指导教师:贺利坚
完成日期:2016年12月12日
题目描述
将字符串t插入到字符串s中,在位置pos后插入。不得使用字符串操作函数,输出组合成的字符串。
输入
输入两个字符串(t和s)和要插入的位置(pos)
输出
输出组合后的字符串
样例输入
qwe
jij
3
样例输出
jijqwe*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char t[20],s[20];
int i,j,pos;
gets(t);
gets(s);
scanf("%d",&pos);
for(i=0; i<strlen(s); i++)
{
printf("%c",s[i]);
if(i+1==pos)
{
for(j=0;j<strlen(t);j++)
printf("%c",t[j]);
}
//printf("%c",s[i]);
}
return 0;
}
运行结果:
知识点总结:
通过学习,进一步掌握了字符串的使用方法。
学习心得:
这个题我错了4遍...一开始思路错了,后来思路对了后某些表达又错了,不过做出来的感觉还是很棒的。