📄 wormsimple.cpp
字号:
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int strcmp1(char *a,char *b) {
int res=0;
while (*a==*b) {
if (a=='\0') break;
res++;a++;b++;
}
return res;
}
int main() {
char str[100];
srand((unsigned)time(NULL));
while (true) {
gets(str);
if (strcmp1(str,"check_status")>=12) {
cerr<<"ready"<<flush;
continue;
}
else if (strcmp1(str,"beetlemove")>=10) {
switch (rand()%4) {
case 0:
cerr<<"action up"<<flush;
break;
case 1:
cerr<<"action down"<<flush;
break;
case 2:
cerr<<"action left"<<flush;
break;
case 3:
cerr<<"action right"<<flush;
}
continue;
}
else if (strcmp1(str,"snailmove")>=9) {
switch (rand()%4) {
case 0:
cerr<<"action up"<<flush;
break;
case 1:
cerr<<"action down"<<flush;
break;
case 2:
cerr<<"action left"<<flush;
break;
case 3:
cerr<<"action right"<<flush;
}
continue;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -