版本比较
打摆器
正文
增加 224 行删除 3 行
1234567898 行未改动10710810911011111211311411589 行未改动205206207208Linux 环境。键位:12/90,对应左边和右边四列。```cpp#include <bits/stdc++.h>#include <termio.h>#include <stdio.h>98 行未改动}}printf("|");E--;if (!E)printf(" cps: %.4lf", cps);else if (cps > E)printf(" ^");printf("\n");}printf("\n%.4lfs\n", time);89 行未改动// }return 0;}```12345678910111298 行未改动11111211311411511611711811989 行未改动209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429打~~钢琴~~井号块练习器。键位:12/90,对应从左到右四列。可在 109~120 修改键位对应 ASCLL。:::info[Linux环境]在终端下直接编译即可。```cpp#include <bits/stdc++.h>#include <termio.h>#include <stdio.h>98 行未改动}}printf("|");E--;if (!E)printf(" kps: %.4lf", cps);else if (cps > E)printf(" ^");printf("\n");}printf("\n%.4lfs\n", time);89 行未改动// }return 0;}```::::::info[Windows环境]编译后运行 exe 文件。```cpp#include <bits/stdc++.h>#include <windows.h>#include <stdio.h>#include <fstream>#include <conio.h>#include <time.h>#include <random>using namespace std;inline void SetPos(int x,int y){COORD pos;pos.X=y*2,pos.Y=x;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}inline void HideCursor() {CONSOLE_CURSOR_INFO cursor_info = {1, 0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);}int c[200][4];int len = 100, id = 1;int score = 0;void init() {int doublecnt = 0;for (int i = 100; i >= 1; i--) {vector <int> num;for (int j = 0; j <= 3; j++) {if (!c[i + 1][j]) {num.push_back(j);}}if ((rand() & 1) && doublecnt < 20) {int id1 = rand() % num.size(), id2 = rand() % num.size();while (id2 == id1) {id2 = rand() % num.size();}c[i][num[id1]] = c[i][num[id2]] = 1;doublecnt++;}else {c[i][num[rand() % num.size()]] = 1;// cout << i <<":" << id1 << " " << id2 << endl;}}vector <pair <int, int> > emp;for (int i = 1; i <= 100; i++) {for (int j = 0; j <= 3; j++) {if (!c[i][j]) {emp.push_back({i, j});}}}// for (int i = 1; i <= 20; i++) {//添加x障碍// int id = rand() % emp.size();// c[emp[id].first][emp[id].second] = 2;// }return;}void print(double cps, double time) {system("cls");SetPos(1, 1);printf("score : %d\n", score);int baifen = id;for (int i = 1; i <= id / 10; i++) {putchar('$');}printf("%d", id - 1);putchar('%');putchar('\n');int E = 12;for (int i = id + 5; i >= id; --i) {putchar('|');for (int j = 0; j <= 3; ++j) {if (c[i][j] == 1) {putchar('#');putchar('#');}else if (c[i][j]) {printf("\\/");}else {putchar(' ');putchar(' ');}}putchar('|');E--;if (cps > E) {printf(" ^");}printf("\n|");for (int j = 0; j <= 3; j++) {if (c[i][j] == 1) {putchar('#');putchar('#');}else if (c[i][j]) {printf("/\\");}else {putchar(' ');putchar(' ');}}putchar('|');E--;if (!E)printf(" cps: %.4lf", cps);else if (cps > E)printf(" ^");printf("\n");}printf("\n%.4lfs\n", time);return;}int change(int x) {if (x == 49) {return 0;}if (x == 50) {return 1;}if (x == 57) {return 2;}return 3;}void solve1() {init();print(0, 0);int ch = getch();DWORD start = GetTickCount();while (1) {if (ch == 49 || ch == 50 || ch == 57 || ch == 48) {if (c[id][change(ch)] == 1) {c[id][change(ch)] = 0;score++;if (c[id][0] != 1 && c[id][1] != 1 && c[id][2] != 1 && c[id][3] != 1) {id++;if (id > len) {DWORD end = GetTickCount();DWORD duration = end - start;double cps = score / (duration * 1.0 / 1000.0), tim = duration * 1.0 / 1000.0;print(cps, tim);cout << "Accept!\n";Sleep(100000);break;}}}else {DWORD end = GetTickCount();DWORD duration = end - start;double cps = score / (duration * 1.0 / 1000.0), tim = duration * 1.0 / 1000.0;print(cps, tim);cout << "Wrong!\n";Sleep(1000);break;}}DWORD end = GetTickCount();DWORD duration = end - start;double cps = score / (duration * 1.0 / 1000.0), tim = duration * 1.0 / 1000.0;print(cps, tim);ch = getch();}return;}void solve2() {cout << "暂未开放!\n";int ch = getch();return;}void solve3() {return;}signed main() {HideCursor();srand(time(NULL));solve1();// while (1) {// system("clear");// cout << "#----------------#\n";// cout << "| Piano blocks |\n";// cout << "#----------------#\n";// cout << "| 1.经典模式 |\n";// cout << "#----------------#\n";// cout << "| 2.无尽模式 |\n";// cout << "#----------------#\n";// cout << "| 3.自定义 |\n";// cout << "#----------------#\n";// cout << "| 4.退出游戏 |\n";// cout << "#----------------#\n";// int ch = getch();// while (ch != 49 && ch != 50 && ch != 51 && ch != 52) {// ch = getch();// }// if (ch == 49) {// solve1();// }else if (ch == 50) {// solve2();// }else if (ch == 51) {// solve3();// }else {// break;// }// }return 0;}```:::未完待续。