SDUT 2124 串结构练习——字符串连接
来源:互联网 发布:javlibrary新域名 12 编辑:程序博客网 时间:2024/06/08 14:13
串结构练习——字符串连接
Time Limit: 1000MSMemory Limit: 65536KB
SubmitStatistic Discuss
Problem Description
给定两个字符串string1和string2,将字符串string2连接在string1的后面,并将连接后的字符串输出。
连接后字符串长度不超过110。
Input
输入包含多组数据,每组测试数据包含两行,第一行代表string1,第二行代表string2。
Output
对于每组输入数据,对应输出连接后的字符串,每组输出占一行。
Example Input
123654abssfg
Example Output
123654abssfg
Hint
#include<cstdio>using namespace std;int main(){ char str1[500],str2[500]; while(scanf("%s %s",str1,str2)!=EOF)//!=EOF是判断是否都到文件结尾,否则死循环,超时 { int i,j; for(i=0;str1[i]!='\0';i++); for(j=0;str2[j]!='\0';j++) { str1[i]=str2[j]; i++; } str1[i]='\0'; printf("%s\n",str1); } return 0;}借鉴其他中输入避免漏掉EOF超时:
#include <stdlib.h> #include <stdio.h> #include <string.h> void conat(char t[], char s1[], char s2[]) { int i=0, k=0; while(s1[i]!='\0') t[k++]=s1[i++]; i=0; while(s2[i]!='\0') t[k++]=s2[i++]; t[k]='\0'; } int main() { char t[111], s1[111], s2[111]; while(gets(s1)!=NULL) { gets(s2); conat(t, s1, s2); puts(t); } }
阅读全文
0 0
- SDUT 2124 串结构练习——字符串连接
- SDUT-串结构练习——字符串连接
- sdut oj2124 串结构练习——字符串连接(动态开辟字符数组)
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 串结构练习——字符串连接
- 小红书2018编程_输出字符串中最大的数
- codeforces 335 C Sorting Railway Cars
- 链表中环的入口结点
- 8.笔记go语言——复杂类型struct,slice,map
- Source Coding and Fountain Codes meet Multipath TCP (MPTCP)
- SDUT 2124 串结构练习——字符串连接
- 9.笔记go语言——方法和接口
- 10.笔记go语言——并发
- final关键字与static静态
- java——int和integer的区别
- 进程间通信——管道
- 11.笔记go语言——内存分配器
- [深度学习论文笔记][ICCV 17 oral]Binarized Convolutional Landmark Localizers for Human Pose Estimation and...
- [[NSBundle mainBundle]pathForResource..取值为空