C语言控制台输出动态表情
有9种不同的表情和手部动作,每个 printFace 函数代表一个不同的猪猪图形,程序将在每个图形之间暂停1秒钟。#include <stdio.h>#include <stdlib.h>
#include <windows.h>
void printFace1() {
printf(" ^___^\n");
printf(" ( o o ) \\_/ \n");
printf(" (=) --|\n");
printf(" `---` / \\ \n");
}
void printFace2() {
printf(" ^___^\n");
printf(" ( - - ) \\_/ \n");
printf(" (>) --|\n");
printf(" `---` / \\ \n");
}
void printFace3() {
printf(" ^___^\n");
printf(" ( x x ) \\_/ \n");
printf(" (<) --|\n");
printf(" `---` / \\ \n");
}
void printFace4() {
printf(" ^___^\n");
printf(" ( o o ) \\_/\n");
printf(" (=) --|\n");
printf(" `---` /\\ \n");
}
void printFace5() {
printf(" ^___^\n");
printf(" ( - - ) \\_/\n");
printf(" (>) --|\n");
printf(" `---` /\\ \n");
}
void printFace6() {
printf(" ^___^\n");
printf(" ( x x ) \\_/\n");
printf(" (<) --|\n");
printf(" `---` /\\ \n");
}
void printFace7() {
printf(" ^___^\n");
printf(" ( o o ) _/\n");
printf(" (=) --|\n");
printf(" `---` \\/ \n");
}
void printFace8() {
printf(" ^___^\n");
printf(" ( - - ) _/\n");
printf(" (>) --|\n");
printf(" `---` \\/ \n");
}
void printFace9() {
printf(" ^___^\n");
printf(" ( x x ) _/\n");
printf(" (<) --|\n");
printf(" `---` \\/ \n");
}
int main() {
while (1) {
system("cls");
printFace1();
Sleep(1000);
system("cls");
printFace2();
Sleep(1000);
system("cls");
printFace3();
Sleep(1000);
system("cls");
printFace4();
Sleep(1000);
system("cls");
printFace5();
Sleep(1000);
system("cls");
printFace6();
Sleep(1000);
system("cls");
printFace7();
Sleep(1000);
system("cls");
printFace8();
Sleep(1000);
system("cls");
printFace9();
Sleep(1000);
}
return 0;
}
本帖最后由 JuncoJet 于 2023-11-16 12:01 编辑
代码没问题,不够优雅
写个优雅的#include <stdio.h>
#include <windows.h>
char *s[]={
" ^___^\n"
" ( o o ) \\_/ \n"
" (=) --|\n"
" `---` / \\ \n",
" ^___^\n"
" ( - - ) \\_/ \n"
" (>) --|\n"
" `---` / \\ \n",
" ^___^\n"
" ( x x ) \\_/ \n"
" (<) --|\n"
" `---` / \\ \n",
" ^___^\n"
" ( o o ) \\_/\n"
" (=) --|\n"
" `---` /\\ \n",
" ^___^\n"
" ( - - ) \\_/\n"
" (>) --|\n"
" `---` /\\ \n",
" ^___^\n"
" ( x x ) \\_/\n"
" (<) --|\n"
" `---` /\\ \n",
" ^___^\n"
" ( o o ) _/\n"
" (=) --|\n"
" `---` \\/ \n",
" ^___^\n"
" ( - - ) _/\n"
" (>) --|\n"
" `---` \\/ \n",
" ^___^\n"
" ( x x ) _/\n"
" (<) --|\n"
" `---` \\/ \n",
};
int main(int argc, char *argv[]){
for(;;){
for(int i=0;i<9;++i){
system("cls");
puts(s);
Sleep(1000);
}
}
}
输出表情在哪个地方使用到了{:1_904:} 呃确实是动态表情 让我想到了使用print("*")输出三角形;www 不错不错 这个输出属实六 多谢,我还停留在汇编时代 能用汇编写吗 这个代码我借用一下,{:1_918:} 老厉害了