⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncopies.c

📁 书名:C语言科学与艺术,以前交钱下载的
💻 C
字号:
/* * File: ncopies.c * --------------- * This file defines the function ConcatNCopies(n, str), * which returns a string consisting of n copies of the * argument str concatenated together. */#include <stdio.h>#include "genlib.h"#include "strlib.h"/* Function prototypes */string ConcatNCopies(int n, string str);/* Main program */main(){    printf("The next line could be used as a section divider.\n");    printf("%s\n", ConcatNCopies(25, "- "));}/* * Function: ConcatNCopies * Usage: newstr = ConcatNCopies(n, str); * -------------------------------------- * This function creates a new string consisting of n * copies of str concatenated together.  For example, * the call ConcatNCopies(4, "AB") returns the string * "ABABABAB".  This implementation is quite inefficient, * both in its running time and use of memory, and should * not be used in practical applications. */string ConcatNCopies(int n, string str){    string result;    int i;    result = "";    for (i = 0; i < n; i++) {        result = Concat(result, str);    }    return (result);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -