第一次写这么长的程序,有错误指出
参考了博主「滑稽果降世」的文章
上代码喽!
#include<bits/stdc++.h>
using namespace std;
void hat(){
cout<<" _________"<<endl;
cout<<" | |"<<endl;
cout<<" |_________|======O"<<endl;
}
void head(){
cout<<" _________"<<endl;
cout<<" | *____* |"<<endl;
cout<<" |_|____|__|"<<endl;
}
void body(){
cout<<"_|||_ | | _|||_"<<endl;
cout<<"|___| | | |___|"<<endl;
cout<<" | |______| |______| |"<<endl;
cout<<" |____|__|__|___|____|"<<endl;
cout<<" |__|__|___|"<<endl;
cout<<" |__|__|___|"<<endl;
cout<<" |__|__|___|"<<endl;
}
void leg(){
cout<<" __________"<<endl;
cout<<" | ______ |"<<endl;
cout<<" | | | |"<<endl;
cout<<" | | | |"<<endl;
cout<<" | | | |"<<endl;
cout<<" | | | |"<<endl;
}
void feat(){
cout<<" _____ _____ "<<endl;
cout<<" <| |> <| |>"<<endl;
cout<<" <| |> <| |>"<<endl;
cout<<" <|_____|> <|_____|>"<<endl;
}
void robot(int x){
for(int i=0;i<x;i++){
hat();
head();
body();
leg();
feat();
}
}
void ead(){
cout<<" *****"<<endl;
cout<<" *.\*/.*"<<endl;
cout<<" *********"<<endl;
cout<<" * *****"<<endl;
cout<<" * *.\*/.*"<<endl;
cout<<" *************"<<endl;
cout<<" * *"<<endl;
cout<<" * *"<<endl;
cout<<" ****"<<endl;
}
void pokemon(int x){
for(int i=0;i<x;i++){
ead();
}
}
int main(){
int b;
string s,c;
while(1){
cout<<"你想要什么:机器人or宝可梦:";
cin>>s;
if(s=="机器人"){
cout<<"你想要多少个机器人:";
cin>>b;
robot(b);
system("pause");
system("cls");
}
else if(s=="宝可梦"){
cout<<"你想要多少个宝可梦:";
cin>>b;
pokemon(b);
system("pause");
system("cls");
}
cout<<"你还要继续玩吗?(y/n):";
cin>>c;
if(c=="n"){
return 0;
}
}
}
没有账号的复制这里⇣
#include<bits/stdc++.h>
using namespace std;
void hat(){
cout<<" _________"<<endl;
cout<<" | |"<<endl;
cout<<" |_________|======O"<<endl;
}
void head(){
cout<<" _________"<<endl;
cout<<" | *____* |"<<endl;
cout<<" |_|____|__|"<<endl;
}
void body(){
cout<<"_|||_ | | _|||_"<<endl;
cout<<"|___| | | |___|"<<endl;
cout<<" | |______| |______| |"<<endl;
cout<<" |____|__|__|___|____|"<<endl;
cout<<" |__|__|___|"<<endl;
cout<<" |__|__|___|"<<endl;
cout<<" |__|__|___|"<<endl;
}
void leg(){
cout<<" __________"<<endl;
cout<<" | ______ |"<<endl;
cout<<" | | | |"<<endl;
cout<<" | | | |"<<endl;
cout<<" | | | |"<<endl;
cout<<" | | | |"<<endl;
}
void feat(){
cout<<" _____ _____ "<<endl;
cout<<" <| |> <| |>"<<endl;
cout<<" <| |> <| |>"<<endl;
cout<<" <|_____|> <|_____|>"<<endl;
}
void robot(int x){
for(int i=0;i<x;i++){
hat();
head();
body();
leg();
feat();
}
}
void ead(){
cout<<" *****"<<endl;
cout<<" *.\*/.*"<<endl;
cout<<" *********"<<endl;
cout<<" * *****"<<endl;
cout<<" * *.\*/.*"<<endl;
cout<<" *************"<<endl;
cout<<" * *"<<endl;
cout<<" * *"<<endl;
cout<<" ****"<<endl;
}
void pokemon(int x){
for(int i=0;i<x;i++){
ead();
}
}
int main(){
int b;
string s,c;
while(1){
cout<<"你想要什么:机器人or宝可梦:";
cin>>s;
if(s=="机器人"){
cout<<"你想要多少个机器人:";
cin>>b;
robot(b);
system("pause");
system("cls");
}
else if(s=="宝可梦"){
cout<<"你想要多少个宝可梦:";
cin>>b;
pokemon(b);
system("pause");
system("cls");
}
cout<<"你还要继续玩吗?(y/n):";
cin>>c;
if(c=="n"){
return 0;
}
}
}