zoukankan      html  css  js  c++  java
  • [YTU]_2781( 重复字符串)

    Description

    输入一个字符串,将其重复若干次,例如,输入goal和5,得到的就是球迷的欢呼:goalgoalgoalgoalgoal。

    不急着欢呼,先补充完整下面的程序。还需要注意的是,给出的程序段中,还藏着一个小Bug,需要你将其改过来。

    #include <iostream>
    #include <cstdio>
    using namespace std;
    void strcopy(char*,char*,int);
    int main( )
    {
         char str1[80];
         char str2[80];
         int n;
         gets(str1);
         cin>>n;
         strcopy(str2,str1,4);
         cout<<str2<<endl;
         return 0;
    }

    Input

    一个待重复的字符串
    重复的次数

    Output

    重复后的文字

    Sample Input

    goal
    5

    Sample Output

    goalgoalgoalgoalgoal
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    using namespace std;
    void strcopy(char*,char*,int);
    int main()
    {
        char str1[80],str2[80];
        int n;
        gets(str1);
        cin>>n;
        strcopy(str2,str1,n);
        cout<<str2<<endl;
        return 0;
    }
    void strcopy(char*str2,char*str1,int n)
    {
        int i;
        str2[0]='';
        for(i=0;i<n;i++)
        {
            strcat(str2,str1);
             
        }
    }

  • 相关阅读:
    mybatis的缓存机制
    mybatis动态SQL
    mybatis关联集合List&分布查询传递多列值
    winrt获取文件MD5码
    在wpf中使用winrt的Toast弹框效果
    winrt控件
    WdatePicker组件不显示
    Thread.Sleep in WinRT
    google 语音api
    UTF8编码转换(C#)
  • 原文地址:https://www.cnblogs.com/sxy201658506207/p/7586401.html
Copyright © 2011-2022 走看看