这是代码:
#include<stdio.h>
int main(){
// prints I stars
void printIStars(int i) {
// Count (call it j) from 1 to i (inclusive)
for (int j = 1; j <= i; j++) {
// Print a star
printf("*");
}
}
// prints a triangle of n stars
void printStarTriangle(int n) {
// Count (call it i) from 1 to n (inclusive)
for (int i = 1; i <= n; i++) {
// Print I stars
printIStars (i);
// Print a newline …Run Code Online (Sandbox Code Playgroud)