1 条题解
-
0
C :
#include <stdio.h> void copy(char *pa,char *pb); int main(void) { char a[80],b[80]; gets(a); printf("OldString=%s",a); copy(a,b); printf("\nNewString=%s",b); return 0; } void copy(char *pa,char *pb) { while(*pa != '\0') { *pb=*pa; pa++; pb++; } *pb='\0'; }
C++ :
#include<bits/stdc++.h> using namespace std; int main() { char s1[80]; cin>>s1; char *s2 = new char[strlen(s1)+1]; strncpy(s2,s1,strlen(s1)); cout<<"OldString=" << s1 << endl; cout<<"NewString="<< s2 << endl; delete []s2; return 0; }
- 1
信息
- ID
- 3091
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者