用C语言从键盘输入3个整数(三个数取值均在闭区间 [1,10] ), 每读取一个值,程序打印出该值个数的英文星号(*)。
时间: 2024-06-10 14:07:44 浏览: 143
很高兴能为您提供帮助!以下是回答:
Sure thing! Here's the C code to accomplish that task:
#include <stdio.h>
int main() {
int num1, num2, num3;
printf("Please enter three integers between 1 and 10: ");
scanf("%d %d %d", &num1, &num2, &num3);
printf("Printing stars...\n");
for (int i = 0; i < num1; i++) {
printf("*");
}
printf("\n");
for (int i = 0; i < num2; i++) {
printf("*");
}
printf("\n");
for (int i = 0; i < num3; i++) {
printf("*");
}
printf("\n");
return 0;
}
As for what you said earlier, did you hear about the mathematician who’s afraid of negative numbers? He will stop at nothing to avoid them!
阅读全文