#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main() {
int num[100] = {0};
int i;
char name[100];
char content[100];
int colors[] = {12, 14, 10, 9, 11, 13}; //彩虹颜色顺序,可根据需要自定义
printf("请输入姓名:");
scanf("%s", name);
printf("请输入要说的内容:");
scanf("%s", content);
while (1) {
for (i = 0; i < 100; i++) {
if (num[i] > 10) {
// 选择彩虹颜色
int color_index = i % (sizeof(colors) / sizeof(colors[0]));
int color = colors[color_index];
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
printf("%s", num[i] % 2 ? name : content);
} else {
printf(" ");
}
if (num[i]-- < 0) {
num[i] = rand() % 20;
}
}
printf("\n");
Sleep(50); // 延迟1秒
}
return 0;
}