版本比较
HSX
正文
增加 114 行删除 18 行
123456789101110121314151617181920192122232425262127282930313233343536373839404142434445462547482749505152535455345657585960616263646566676869707172737445757677787980818247838485498687518889549091925758939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361376013813914014114214314414514614714814915062636415166152153154155156157158159160161162163164```cpp#include <windows.h>#include <iostream>#include <fstream>#include <conio.h>#include <vector>#include <cstdio>#include <random>#include <ctime>
#define KEY 4#define LEN 256#define MAX_LEN 16384#define DIS 16
using namespace std;
mt19937 rng(time(0));
const int TOT=LEN+DIS+5;
int note[TOT];struct Tap{ int time; char c; };
int pts;bool note[TOT][5];
int pts,lpts,cb,tot;
int LEN;
int map[130]={};int cnt[TOT]={};int sum[TOT]={};
const int Base[8]={2,3,5,7,11,13,17,19};
bool read();
void init();
Tap readTap();
int main(){ for(int i=1; i<=LEN; i++) if(!read()) { note[i]=rng()%4; return 0; } for(int i=LEN-DIS; i>=-DIS; i--) { system("cls"); if(i!=LEN-DIS) { printf("%.2lf\%\n",100.0*(pts*1.0/(LEN-(i+DIS)))); printf("%.2lf\%\n",100.0*(pts*1.0/(sum[i+DIS+1]))); } if(cb >= 3) { printf(" COMBO\n %d\n",cb); } else { printf("\n\n"); } if(i<=1) { for(int j=i; j<=1; j++) { printf("\n"); } } for(int j=max(1,i); j<=i+DIS; j++) { for(int k=1; k<=note[j]; k++) for(int k=0; k<=KEY-1; k++) { if(note[j][k]) { printf("__"); } else { printf(" "); printf(" "); } } printf("__\n"); printf("\n"); } //printf("\n"); for(int j=1; j<=KEY; j++) { printf("__"); printf("--"); } printf("\n"); char ch=_getch(); if((ch=='g' && note[i+DIS]==0) || (ch=='h' && note[i+DIS]==1) || (ch=='j' && note[i+DIS]==2) || (ch=='k' && note[i+DIS]==3)) char ch[5]={'\0','\0','\0','\0','\0'}; int rd=1,ans=1; for(int j=1; j<=cnt[i+DIS]; j++) { ch[j]=_getch(); rd*=map[ch[j]]; } for(int j=0; j<=KEY-1; j++) { if(note[i+DIS][j]) { ans*=Base[j]; } } if(ans == rd) { cb+=cnt[i+DIS]; pts+=cnt[i+DIS]; } else { cb=0; } } return 0;}
bool read(){ ifstream fin; fin.open("chart.hsx",ios::in); fin>>LEN; if(LEN > MAX_LEN) { printf("ERR : Fail To Read The Chart\n"); return false; } map['d']=2; map['f']=3; map['j']=5; map['k']=7; for(int i=1; i<=LEN; i++) { for(int j=0; j<=KEY-1; j++) { pts++; int tmpn=0; fin>>tmpn; if(tmpn) { tot++; cnt[i]++; note[i][j]=true; } else { note[i][j]=false; } } //cout<<i+DIS<<endl; //cout<<ch<<" "<<note[i+DIS]<<" "<<pts<<endl; //system("pause"); } return 0; return true;}
void init(){ sum[LEN]=cnt[LEN]; for(int i=LEN-1; i>=1; i--) { sum[i]=cnt[i]+sum[i+1]; } return;}```