1 条题解

  • 0
    @ 2025-4-14 18:43:48

    C :

    #include  <stdio.h>
    int main()
    {	
    	int i;	
    	char ch;	
    	char str[100];	
    	scanf("%s", str);	
    	scanf(" %c", &ch);	
    	for (i=0; str[i]!='\0'; i++)	
    	{		
    		if (i%2==0)	
    			str[i]=ch;
    			
    	}
    	printf("%s\n", str);	
    	return 0;
    }
    

    C++ :

    #include<iostream>
    #include<string>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    int main()
    {
    	string n;
    	cin>>n;int u=n.length();
    	char k;cin>>k;
    	for(int o=0;o<=u;o+=2)
    	n[o]=k;
    	cout<<n;
    }
    
    • 1

    信息

    ID
    3289
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者