- 问答
- 2018-01-31 12:56:15 @
.
236 条评论
-
______________ LV 6 @ 2018-02-26 12:12:06
#include <bits/stdc++.h>
using namespace std;
int main()
{
char a1[201],b1[201],c1[201];
int a[201],b[201],c[201];
int lena,lenb,lenc,o,i,j;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
cin>>a1>>b1;
if(strlen(a1)<strlen(b1) || (strlen(a1)==strlen(b1) && strcmp(a1,b1)<0))
swap(a1,b1);
o=0;
lena=strlen(a1);
lenb=strlen(b1);
for(i=0;i<lena;i++)
a[lena-i]=a1[i]-'0';
for(i=0;i<lenb;i++)
b[lenb-i]=b1[i]-'0';
lenc=1;
for(i=1;i<=lenb;i++)
{
o=0;
for(j=1;j<=lena;j++)
{
c[i+j-1]=a[j]*b[i]+o+c[i+j-1];
o=c[i+j-1]/10;
c[i+j-1]%=10;
}
c[i+lena]=o;
}
lenc=lena+lenb;
while(c[lenc]==0&&lenc>1)lenc--;
for(i=lenc;i>=1;i--)
cout<<c[i];
return 0;
} -
2018-02-26 08:43:06@
#include <bits/stdc++.h>
using namespace std;
char a[101][101];
bool r[101][101];
int main(){
memset(r,false,sizeof(r));
int n,i,j,k,m;
cin>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
cin>>a[i][j];
cin>>m;
for(k=1;k<=m;j++){
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(a[i][j]=='@'){
if(a[i+1][j]=='.') r[i+1][j]==true;
if(a[i-1][j]=='.') r[i-1][j]==true;
if(a[i][j+1]=='.') r[i][j+1]==true;
if(a[i][j-1]=='.') r[i][j-1]==true;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(r[i][j]==true)
a[i][j]='@';
}
int s;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(a[i][j]=='@')
s++;
printf("%d",s);
return 0;
} -
2018-02-08 13:53:03@
多久没上了
-
2018-02-05 13:25:46@
//贪吃蛇
#include <cstdio>
#include <iostream>
#include <ctime>
#include <conio.h>
#include <windows.h> //停顿:Sleep();
#include <cstdlib> //清屏:system("cls");
#include <cstring> //1:'◎' 2:'⊙' 3:'▲' 4:'◆' 5:'■'
using namespace std;
int a[100][100],dir[100][100];
//string guo[5]={'▲','◆','■','▼','★'};
int fx[4][2]={{0,-1},{1,0},{0,1},{-1,0}}; //ap来记录奖励块的分
int n,m,ff,f=1,t=55,T=55,ap=10,egg[2],danshu,headx,heady,endx,endy,point=0,apple=0,fangx,stopp=0,panduan=0; //ff用来判断 panduan 0:中途退出;1:咬到自己;2:重置
int lastfx;
int zuobi=0;
int fff[110][110];
string print[4][4]={{"═","╔"," ","╚"},{"╝","║","╚"," "},{" ","╗","═","╝"},{"╗"," ","╔","║"}};void color(int a)//颜色函数
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}void gotoxy(int x,int y)//位置函数(行为x 列为y)
{
COORD pos;
pos.X=2*y;
pos.Y=x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}void reset(){
system("cls");
color(7); printf(" ★"); color(10); printf("贪吃蛇"); color(11); printf("★\n\n"); color(7);
printf("⊙打印若有错位请调整窗口大小或按r重输小点的数⊙\n\n 请输入场地大小(格式:行数 列数) 推荐(20 20) \n\n>>");
scanf("%d%d",&n,&m);
system("cls");
color(14);
for (int i=1; i<=m; i++){gotoxy(0,i);printf("※");gotoxy(n+1,i);printf("※");}
for (int i=1; i<=n; i++){gotoxy(i,0);printf("※");gotoxy(i,m+1);printf("※");}
color(10);
memset(fff,0,sizeof(fff));
gotoxy(0,0); printf("┍");
gotoxy(n+1,0); printf("┕");
gotoxy(0,m+1); printf("┑");
gotoxy(n+1,m+1); printf("┙");
color(7);
gotoxy(0,m+5); printf("方向:a/s/d/w | 1/2/3/5");
gotoxy(1,m+5); printf("暂停:p | 0");
gotoxy(2,m+5); printf("减速:q/j | 4/7");
gotoxy(3,m+5); printf("加速:e/k | 6/9");
gotoxy(4,m+5); printf("重置:r | .");
gotoxy(5,m+5); printf("地图:g | +");
headx=endx=endy=1; heady=3;
f=1; ff=3;
memset(a,1,sizeof(a));
memset(dir,0,sizeof(dir));
a[1][1]=a[1][2]=a[1][3]=0;
gotoxy(1,1); printf("⊙");
gotoxy(1,2); printf("⊙");
gotoxy(1,3); printf("◎");
dir[1][1]=dir[1][2]=dir[1][3]=2;
apple=0; fangx=2; point=0; danshu=0; lastfx=2; stopp=0;
if (zuobi) {color(12); gotoxy(12,m+5); printf("作弊可耻!"); gotoxy(n+4,0); printf("做了弊还没路走那就救不了你了,乖乖重来吧......"); color(7);}
}void haha(){
char ch=getch();
if ((ch=='a' | ch=='1') && dir[headx][heady]!=2){fangx=0; return;}
if ((ch=='s' | ch=='2') && dir[headx][heady]!=3){fangx=1; return;}
if ((ch=='d' | ch=='3') && dir[headx][heady]!=0){fangx=2; return;}
if ((ch=='w' | ch=='5') && dir[headx][heady]!=1){fangx=3; return;}
if (ch=='p' | ch=='0'){stopp=(stopp+1)%2; return;}
if (ch=='q' | ch=='4'){T+=10; if (T>=1005) T=1005; return;}
if (ch=='e' | ch=='6'){T-=10; if (T<=1) T=2; return;}
if (ch=='j' | ch=='7'){T+=1; if (T>=1005) T=1005; return;}
if (ch=='k' | ch=='9'){T-=1; if (T<=1) T=2; return;}
if (ch=='r' | ch=='.'){ff=2; f=0; panduan=0; return;}
if (ch=='h' | ch=='8'){
zuobi+=1; zuobi%=2;
if (zuobi) {color(12); gotoxy(12,m+5); printf("作弊可耻!"); gotoxy(n+4,0); printf("做了弊还没路走那就救不了你了,乖乖重来吧......"); color(7);}
else {printf(" "); gotoxy(m+4,0); printf(" ");}
}
if (ch=='g' |ch=='+'){
gotoxy(n+50,0);
printf("现在切换到地图编辑模式\n\nq/4 为开始放置模式(光标移动过的痕迹会留下障碍物)\n\ne/6 为取消放置障碍物模式\n\nj/0 为橡皮模式(再按一次退出橡皮模式)\n\n按 h/+ 继续游戏\n\n");
printf("\n按任意键开始编辑地图");
color(13);
int x=1,y=1, dfx, moshi=0;
ch=getch(); gotoxy(0,0); gotoxy(1,1);
while (ch!='h' && ch!='+'){
if (ch=='a' | ch=='1') dfx=0;
else if (ch=='s' | ch=='2') dfx=1;
else if (ch=='d' | ch=='3') dfx=2;
else if (ch=='w' | ch=='5') dfx=3;
else dfx=5;
if (ch=='q' | ch=='4') moshi=1;
if (ch=='e' | ch=='6') moshi=0;
if (ch=='j' | ch=='0') if (moshi-2) moshi=2; else moshi=0;
if (dfx<=4){
if (x+fx[dfx][0]>0 && x+fx[dfx][0]<=n && y+fx[dfx][1]>0 && y+fx[dfx][1]<=m){x+=fx[dfx][0]; y+=fx[dfx][1];}
if (x>0 && x<=n && y>0 && y<=m){
gotoxy(x,y);
if (moshi==1 && a[x][y] && !fff[x][y]){a[x][y]=0; fff[x][y]=1; printf("□");}
if (moshi==2 && fff[x][y]){a[x][y]=1; fff[x][y]=0; printf(" ");}
gotoxy(x,y);
}
}
ch=getch();
}
color(7);
}
}void findegg(){
srand(time(NULL));
int aa=1;
while (!a[egg[0]][egg[1]]){egg[0]=(rand()%(n))+1; egg[1]=(rand()%m)+1;}
a[egg[0]][egg[1]]=0;
point+=ap;
gotoxy(egg[0],egg[1]); if (!apple){printf("★"); ap=8000/T; if (ap>=200) ap=200;}else {printf("●"); ap=10;}
apple++; apple=apple%10;
gotoxy(n+2,0); printf("距离下一个奖励蛋还有 "); color(11); cout <<9-(8+apple)%10; color(7); printf(" 个");
danshu++;
return;
}int gg(){
if (ff==0) return(0);
if (ff==1) {gotoxy(n+2,1); Sleep(3000); gotoxy(n+26,1); gotoxy(n+10,0); printf("哦豁~ 你咬到自己了o( ̄▽ ̄)d\n\n\n你共吃蛋 %d 个\n\n\n你共得分 %d 分,恭喜!\n\n\n等一下就继续",danshu,point); while (kbhit()) char ch=getch(); Sleep(5000); if (kbhit) return(1);}
if (ff==2) return(1);
}void dong(){
gotoxy(11,m+3); printf("当前的蛋有 %d 分 ",ap);
if (ap-3>10) ap-=3;
if (ap!=10){
gotoxy(egg[0],egg[1]);
color(ap%10);
printf("★");
color(7);
}int x,y;
x=(headx+fx[fangx][0]-1+n)%(n)+1; y=(heady+fx[fangx][1]-1+m)%(m)+1;
dir[headx][heady]=fangx;
if(x==egg[0] && y==egg[1]){
gotoxy(headx,heady); cout <<print[lastfx][fangx];
dir[headx][heady]=fangx;
headx=x; heady=y; a[x][y]=0;
gotoxy(headx,heady); printf("◎");
findegg();
}
else if (a[x][y]){
gotoxy(headx,heady); cout <<print[lastfx][fangx];
headx=x; heady=y; a[x][y]=0;
gotoxy(headx,heady); printf("◎");
gotoxy(endx,endy); printf(" "); a[endx][endy]=1;
x=endx; y=endy;
endx+=fx[dir[x][y]][0]; endx=(endx-1+n)%(n)+1;
endy+=fx[dir[x][y]][1]; endy=(endy-1+m)%(m)+1;
dir[x][y]=-1;
}
else if(!zuobi){f=0; ff=1;}dir[headx][heady]=fangx;
lastfx=fangx;
return;
}int main(){
while (1){
srand(time(NULL));
reset();
egg[0]=(rand()%n-1)+2; egg[1]=(rand()%m)+1;
a[egg[0]][egg[1]]=0;
gotoxy(egg[0],egg[1]); if (apple){printf("★"); ap=100;}else printf("●");
while (f){
if (kbhit()) haha();
gotoxy(9,m+5); printf("吃蛋:%d 个",danshu);
gotoxy(8,m+5); printf("速度: %d ",1005-T);
//while (stopp) {Sleep(10); if (kbhit()) haha();}
Sleep(1); t=(t-1+T)%T;
if (t==0 && !stopp) dong();
gotoxy(7,m+5); printf("得分:%d 分",point);
gotoxy(12,m+5);
}
if (!gg()) return 0;
}
return 0;
} -
2018-02-05 12:44:31@
//俄罗斯方块
#include<cstdio>
#include<windows.h>
#include<ctime>
int a[24][17],i,j,tim=800,ti=800,shape=0,b,bn,ta[4][4],turn[4][4],nex[4][4],nextshape,add=0,score=0,speed=1,ok=1,mouse=0,best=0;
void Place(const int x, const int y)
{ COORD PlaceCursorHere;PlaceCursorHere.X = y;PlaceCursorHere.Y = x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), PlaceCursorHere);
return;
}
void color(int x)
{SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);}
void appear()
{for(i=3;i<=22;i++) for(j=1;j<=15;j++) if(a[i][j]!=0) {Place(i-2,2*j); printf("■");}}
void disappear()
{for(i=3;i<=22;i++) for(j=1;j<=15;j++) if(a[i][j]==2) {Place(i-2,2*j); printf(" ");}}
int search(int x0,int y0,int x,int y)
{
POINT pt; HWND h=GetForegroundWindow(); GetCursorPos(&pt); ScreenToClient(h,&pt);
if(pt.x>=x0&&pt.y>=y0&&pt.x<=x&&pt.y<=y)
{
if(mouse!=0) {Sleep(100); return 2;} else return 1;
}
else return 0;
}
void button(int x)
{
int m=x*10;
if(x<3)
{
Place(22,m); printf("┌┄┄┄┐");
Place(23,m);
{
if(x==0) {if(ok!=0) printf("┆start ┆"); else printf("┆pause ┆");}
if(x==1) printf("┆reset ┆"); if(x==2) printf("┆ exit ┆");
}
Place(24,m); printf("└┄┄┄┘");
}
else
{
Place(9,m-33); printf("┌┄┄┐");
Place(10,m-33);
{
if(x==4) printf("┆yes ┆"); else printf("┆ no ┆");
}
Place(11,m-33); printf("└┄┄┘");
}
}
void menu(int x)
{
int k,l;
if(x==0)
{
if(ok!=0) {ok=0; return;}
else while(1)
{
mouse=GetAsyncKeyState(VK_LBUTTON);
Place(9,13); printf("pause");
if(search(7,360,71,390)==2) break; Sleep(50);
}
Place(9,12); for(j=1;j<=6;j++) printf(" "); //appear();}
else
{
for(i=1;i<=20;i++) for(j=2;j<=30;j++) {Place(i,j); printf(" ");}
Place(7,2); for(i=1;i<=15;i++) printf("┄"); Place(12,2); for(i=1;i<=15;i++) printf("┄");
Place(8,6); printf("Do you want to "); if(x==1) printf("reset?"); if(x==2) printf("exit?");
button(4); button(5);
while(1)
{
mouse=GetAsyncKeyState(VK_LBUTTON);
for(i=0;i<=1;i++)
{
k=search(63+i*80,150,110+i*80,180);
if(k!=2) {if(k==1) color(15); else color(7); button(i+4);}
else
{for(l=7;l<=12;l++) for(j=2;j<=30;j++) {Place(l,j); printf(" ");}
if(i==0) {if(x==1) ok=2; else exit(0);} return;
}
}
Sleep(50);
}
}
}
void click()
{
for(i=0;i<=2;i++)
{ mouse=GetAsyncKeyState(VK_LBUTTON);
int k=search(i*80+7,360,i*80+71,390);
if(k!=2) {if(k==1) color(15); else color(7); button(i); color(7);}
else{menu(i); return;}
}
Sleep(50);
}
void ss()
{
Place(9,39); printf("%d",score);
if(score>=speed*100)
{
speed++; ti=ti-200;
if(ti<0) ti=0;
else
{
for(i=1;i<=4;i++)
{
Place(9,12); printf("speed up!"); Sleep(70);
Place(9,12); for(j=1;j<=9;j++) printf(" "); Sleep(70);
}Sleep(200);
}
}
if(best<score) best=score;
appear(); Place(12,39); printf("%d",speed); Place(15,39); printf("%d",best);
}
void replace()
{
for(i=1;i<=20;i++) for(j=2;j<=30;j++) {Place(i,j); printf(" ");}
for(i=0;i<=22;i++) for(j=1;j<=15;j++) a[i][j]=0; for(i=1;i<=15;i++) a[23][i]=1; for(i=1;i<=23;i++) {a[i][0]=1; a[i][16]=1;} ss();
tim=800;ti=800;shape=0;add=0;score=0;speed=1;
}
void change(int x)
{
int q=0,l;
for(l=1;l<=x;l++)
{
for(j=0;j<=2+add;j++)
{
for(i=2+add;i>=0;i--)
{
turn[j][q]=ta[i][j];
q++;
if(q>2+add) q=0;
}
}
for(i=0;i<=3;i++) for(j=0;j<=3;j++) ta[i][j]=turn[i][j];
}
}
void born()
{
int x,q=0; srand(time(NULL)); bn=b; shape=nextshape; x=rand()%12+1; if(b==5&&x>1) {x--; add=1;}
for(i=0;i<=2+add;i++) for(j=x;j<=x+2+add;j++) {a[i][j]=nex[i][q]; q++; if(q>2+add) q=0;}add=0;
}
void next()
{
srand(time(NULL)); b=rand()%7; nextshape=rand()%4; add=0;
for(i=3;i<=6;i++) for(j=37;j<=45;j++) {Place(i,j); printf(" ");}
for(i=0;i<=3;i++) for(j=0;j<=3;j++) nex[i][j]=turn[i][j]=ta[i][j]=0; ta[1][1]=2;
if(b==0) ta[1][2]=ta[1][0]=ta[0][1]=2; if(b==1) ta[1][2]=ta[1][0]=ta[0][0]=2; if(b==2) ta[1][2]=ta[1][0]=ta[0][2]=2; if(b==3) ta[1][0]=ta[0][1]=ta[0][2]=2;
if(b==4) ta[0][0]=ta[0][1]=ta[1][2]=2; if(b==5) {ta[1][0]=ta[1][2]=ta[1][3]=2; add=1;} if(b==6) ta[0][0]=ta[0][1]=ta[1][0]=2;
if(nextshape>0&&b!=6)
{change(nextshape); for(i=0;i<=3;i++) for(j=0;j<=3;j++) {nex[i][j]=turn[i][j]; if(nex[i][j]==2) {Place(i+3,j*2+37); printf("■");}}}
else {for(i=0;i<=3;i++) for(j=0;j<=3;j++) {nex[i][j]=ta[i][j]; if(nex[i][j]==2) {Place(i+3,j*2+37); printf("■");}}}
}
void clear()
{
int c=0,f=0,l[23],s=0,k;
for(i=3;i<=22;i++)
{
l[i]=0;
for(j=1;j<=15;j++) c=a[i][j]+c;
if(c==15)
{
for(j=1;j<=15;j++) a[i][j]=0;
for(k=i-1;k>=2;k--) for(j=1;j<=15;j++) a[k+1][j]=a[k][j];
f++; l[i]=1; s=5;
}
c=0;
}
score=score+f*10; while(f>1) {score=score+f*5; f--;} f=0;
while(s>0)
{
for(i=22;i>=3;i--) if(l[i]==1) { Place(i-2,2); for(j=1;j<=15;j++) printf("■");}Sleep(70);
for(i=22;i>=3;i--) if(l[i]==1) { Place(i-2,2); for(j=1;j<=30;j++) printf(" ");}Sleep(70);s--;
}
for(i=3;i<=22;i++) for(j=1;j<=15;j++) {Place(i-2,2*j); printf(" ");} appear();
}
void control()
{
int up,down,right,left,c=0,d=0,x,y,no=0,k,l=0,q=0; k=shape; add=0;
up=GetAsyncKeyState(VK_UP); down=GetAsyncKeyState(VK_DOWN); right=GetAsyncKeyState(VK_RIGHT); left=GetAsyncKeyState(VK_LEFT);
if(down!=0) { tim=0;}
if(left!=0||right!=0)
{
Sleep(100);disappear();
for(i=0;i<=22;i++) for(j=1;j<=15;j++)
{
if(a[i][j]==2&&a[i][j-1]!=1) c++; if(a[i][j]==2&&a[i][j+1]!=1) d++;
}
for(i=0;i<=22;i++) for(j=1;j<=15;j++) if(left!=0&&c==4&&a[i][j]==2) {a[i][j-1]=a[i][j]; a[i][j]=0;}
for(i=0;i<=22;i++) for(j=15;j>=1;j--) if(right!=0&&d==4&&a[i][j]==2) {a[i][j+1]=a[i][j];a[i][j]=0;} appear();
}
if(up!=0&&bn!=6)
{
Sleep(150); disappear();
for(i=0;i<=22;i++)
{
for(j=1;j<=15;j++) if(a[i][j]==2) {x=i; no=1; break;}
if(no==1) break;
} no=0;
for(j=1;j<=15;j++)
{
for(i=0;i<=22;i++) if(a[i][j]==2) {y=j; no=1; break;}
if(no==1) break;
} no=0;
if(k==1) y--; if(k==2) x--; add=0;
if(bn==5) {add=1; if(k==0||k==2) x--; if(k==1||k==3) y--;}
for(i=0;i<=3;i++) for(j=0;j<=3;j++) ta[i][j]=a[x+i][y+j];
if(bn>=0&&bn<5)
{
if(k==0) ta[2][0]=0; if(k==1) ta[0][0]=0; if(k==2) ta[0][2]=0; if(k==3) ta[2][2]=0;
}
if(bn==5)
{ if(k==0) ta[0][3]=ta[2][0]=ta[2][1]=ta[3][1]=ta[3][0]=0;
if(k==1) ta[0][0]=ta[1][0]=ta[0][1]=ta[1][1]=ta[3][3]=0;
if(k==2) ta[3][0]=ta[0][2]=ta[0][3]=ta[1][2]=ta[1][3]=0;
if(k==3) ta[0][0]=ta[2][2]=ta[2][3]=ta[3][2]=ta[3][3]=0;
}
for(i=0;i<=2+add;i++) for(j=0;j<=2+add;j++) if(ta[i][j]!=1) l++;
if(l==9+add*7)
{
change(1);
for(i=0;i<=22;i++) for(j=1;j<=15;j++) if(a[i][j]==2) a[i][j]=0;
for(i=0;i<=2+add;i++) for(j=0;j<=2+add;j++) if(turn[i][j]==2) a[x+i][y+j]=turn[i][j]; shape++;
}
if(shape>3) shape=0; appear();
}
}
int main()
{
int k,start,finish,d; printf("┌"); for(i=1;i<=15;i++) printf("┄"); printf("┐\n");
for(i=1;i<=20;i++) printf("┆\n"); printf("└");
for(i=1;i<=15;i++) printf("┄"); printf("┘"); for(i=1;i<=20;i++) {Place(i,32); printf("┆\n");}
Place(2,37); printf("NEXT"); Place(8,37); printf("SCORE"); Place(14,37); printf("BEST"); Place(11,37); printf("SPEED");
for(i=0;i<=2;i++) button(i);
while(ok==1) click();
while(ok!=1)
{
replace(); next();
while(1)
{
born();
next();
while(1)
{
appear();
k=0;
start=clock();
while(1)
{
finish=clock(); d=finish-start;
if(d>=tim) break;
control(); click(); if(ok==2) break;
}
if(ok==2) break; disappear();
for(i=22;i>=0;i--) for(j=1;j<=15;j++) if(a[i][j]==2&&a[i+1][j]!=1) k++;
if(k==4)
{
for(i=22;i>=0;i--) for(j=1;j<=15;j++) if(a[i][j]==2)
{
a[i+1][j]=2;a[i][j]=0;
}
}
else
{
for(i=22;i>=0;i--) for(j=1;j<=15;j++) if(a[i][j]==2) a[i][j]=1;
break;
}
tim=ti; appear();
}
if(ok==2) break;
appear();clear();ss();
for(i=1;i<=15;i++) if(a[2][i]==1) {ok=1; break;}
}
if(ok==2) {ok=0; continue;}
for(i=1;i<=20;i++) for(j=2;j<=30;j++) {Place(i,j); printf(" ");}
Place(9,12); printf("GAME OVER!");
while(ok==1) click();
}
return 0;
} -
2018-02-05 12:43:45@
//井字棋
#include<cstdio>
#include<windows.h>
#include<ctime>
int a[4][4],i,j,xc,yc,mouse=0,ok=0,record[2][9],foot=9,winner,first=0,who=0;
void Place(const int x, const int y)
{ COORD PlaceCursorHere;PlaceCursorHere.X = y;PlaceCursorHere.Y = x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), PlaceCursorHere);
return;
}
void color(int x)
{SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);}
int search(int x0,int y0,int x,int y)
{
mouse=GetAsyncKeyState(VK_LBUTTON);
POINT pt; HWND h=GetForegroundWindow(); GetCursorPos(&pt); ScreenToClient(h,&pt);
if(pt.x>=x0&&pt.y>=y0&&pt.x<=x&&pt.y<=y)
{
if(mouse!=0) {Sleep(100); return 2;} else return 1;
}
else return 0;
}
bool check(int x)
{
int b=0,c=0,d=0,e=0;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++) {b+=a[i][j]; c+=a[j][i];} d+=a[i][i]; e+=a[i][4-i];
if(b==x||c==x||d==x||e==x) return true; b=0; c=0;
}
return false;
}
void pcmove()
{
int x=10,b=0,c=0,d=0,e=0; xc=0; yc=0;
while(x>0)
{
for(i=1;i<=3;i++)
{
b=0; c=0; for(j=1;j<=3;j++) {b+=a[i][j]; c+=a[j][i];} d+=a[i][i]; e+=a[i][4-i];
if(b==x) {for(j=1;j<=3;j++) if(a[i][j]==0) {xc=i; yc=j; return;}} if(c==x) {for(j=1;j<=3;j++) if(a[j][i]==0) {xc=j; yc=i; return;}}
if(d==x) {for(j=1;j<=3;j++) if(a[j][j]==0) {xc=yc=j; return;}} if(e==x) {for(j=1;j<=3;j++) if(a[j][4-j]==0) {xc=j; yc=4-j; return;}}
} x-=8;
}
if(a[2][2]==0) {xc=yc=2; return;} x=2;
while(x>0) {for(i=1;i<=3;i+=x) for(j=1;j<=3;j+=x) if(a[i][j]==0) {xc=i; yc=j; return;} x--;}
}
void show()
{
int x=foot;
for(i=1;i<=3;i++) for(j=1;j<=3;j++) if(a[i][j]!=0) {if(a[i][j]==1) color(15); else color(11); Place(2*i-1,4*j-2); printf("●");}
color(15); Place(7,0);
if(who==0) {if(foot%2==1) printf("1号"); else printf("2号");} else printf("电脑");
if(who==0||first==1) x--;
printf("下子:(%d,%d)",record[0][8-x],record[1][8-x]);
}
void button(int x)
{
if(x<3)
{
Place(x*3,15); printf("┌┄┄┐");
Place(x*3+1,17); if(x==0){if(ok==0) printf("开始"); else printf("悔棋");} if(x==1) printf("重来"); if(x==2) printf("退出");
Place(x*3+2,15); printf("└┄┄┘");
}
if(x>2&&x<6)
{
Place(10,(x-4)*7); printf("┌┄┐");
Place(11,(x-4)*7+2); if(x==4) printf("是"); else printf("否");
Place(12,(x-4)*7); printf("└┄┘");
}
if(x>5&&x<8)
{
Place(10,(x-6)*12); printf("┌┄┄┄┄┐");
Place(11,(x-6)*12+2); if(x==6) printf("人机对战"); else printf("人人对战");
Place(12,(x-6)*12); printf("└┄┄┄┄┘");
}
if(x>7)
{
Place(10,(x-8)*12); printf("┌┄┄┄┄┐");
Place(11,(x-8)*12+2); if(x==8) printf(" 我先手 "); else printf("电脑先手");
Place(12,(x-8)*12); printf("└┄┄┄┄┘");
}
}
void menu(int x)
{
int k,l;
if(x==0)
{
if(ok==0) {ok=1; return;}
else if(9-foot>1)
{
foot+=2; for(i=9-foot;i<=11-foot;i++) {a[record[0][i]][record[1][i]]=0; record[0][i]=record[1][i]=0;}
for(i=1;i<=3;i++) for(j=1;j<=3;j++) {Place(2*i-1,4*j-2); printf(" ");} show();
}
}
if(x>0&&x<3)
{
for(l=10;l<=12;l++) for(j=1;j<=22;j++) {Place(l,j); printf(" ");}
Place(9,1); printf("你想"); if(x==1) printf("重来吗?"); if(x==2) printf("退出吗?");
button(4); button(5);
while(1)
{
mouse=GetAsyncKeyState(VK_LBUTTON);
for(i=0;i<=1;i++)
{
k=search(7+i*55,165,40+i*55,200);
if(k!=2) {if(k==1) color(15); else color(7); button(i+4);}
else
{for(l=9;l<=12;l++) for(j=1;j<=12;j++) {Place(l,j); printf(" ");}
if(i==0) {if(x==1) ok=2; else exit(0);} return;
}
}
Sleep(50);
}
}
if(x>2&&x<5) {if(x==3) {who=1; return;} else {who=0; return;}}
if(x>4) {if(x==5) {first=0; return;} else {first=1; return;}}
}
void click()
{
for(i=0;i<=2;i++)
{ mouse=GetAsyncKeyState(VK_LBUTTON);
int k=search(125,i*50+5,175,i*50+40);
if(k!=2) {if(k==1) color(15); else color(7); button(i); color(7);}
else{menu(i); return;}
}
Sleep(50);
}
void humove()
{
while(1)
{
for(i=1;i<=3;i++) for(j=1;j<=3;j++) if(search(7+(i-1)*32,7+(j-1)*32,7+i*32,7+j*32)==2&&a[j][i]==0)
{if(who==0&&foot%2!=1) a[j][i]=5; else a[j][i]=1; record[0][9-foot]=j; record[1][9-foot]=i; return;} click(); if(ok==2) return;
}
}
void replace()
{
int k,l,p,q;
Place(7,0); for(i=1;i<=15;i++) printf(" "); for(i=1;i<=3;i++) for(j=1;j<=3;j++) {Place(2*i-1,4*j-2); printf(" "); a[i][j]=0;}
for(i=0;i<2;i++) for(j=0;j<9;j++) record[i][j]=0; foot=9; winner=0; first=0; who=0; ok=1; button(6); button(7);
while(1)
{
for(i=0;i<=1;i++)
{
mouse=GetAsyncKeyState(VK_LBUTTON); k=search(i*80+7,165,i*80+103,200); q=search(125,105,175,140);
if(k!=2) {if(k==1) color(15); else color(7); button(i+6); color(7);}
else
{
menu(i+3); for(l=10;l<=12;l++) for(j=1;j<=22;j++) {Place(l,j); printf(" ");}
if(who==1)
{
button(7); button(8);
while(1)
{
for(j=0;j<=1;j++)
{
mouse=GetAsyncKeyState(VK_LBUTTON); k=search(j*80+7,165,j*80+103,200); q=search(125,105,175,140);
if(k!=2) {if(k==1) color(15); else color(7); button(j+8); color(7);}
else{menu(j+5); for(l=10;l<=12;l++) for(p=1;p<=22;p++) {Place(l,p); printf(" ");} return;}
if(q!=2) {if(q==1) color(15); else color(7); button(2); color(7);} else menu(2);
} Sleep(50);
}
}
return;
}
if(q!=2) {if(q==1) color(15); else color(7); button(2); color(7);} else menu(2);
}
Sleep(50);
}
}
int main()
{
printf("┌─┬─┬─┐\n\n├─┼─┼─┤\n\n├─┼─┼─┤\n\n└─┴─┴─┘\n\n");
for(i=0;i<3;i++) button(i);
while(ok==0) click();
while(1)
{
replace();
while(foot>0&&ok!=0)
{
if(first!=1) {humove(); show(); if(check(3)) {winner=1; ok=0; break;} foot--; if(foot<=0||ok==0||ok==2) break;}
if(who==0&&check(15)) {winner=2;ok=0;break;}
if(who!=0) {pcmove(); record[0][9-foot]=xc; record[1][9-foot]=yc; a[xc][yc]=5; show(); if(check(15)) {winner=2;ok=0;} foot--; first=0;}
}
if(ok==2) {ok=1; continue;} Place(7,0); for(i=1;i<=15;i++) printf(" ");
Place(7,4); color(15); if(winner==0) printf("平局!");
if(who!=0) {if(winner==1) printf("你赢了!"); if(winner==2) printf("你输了!"); Sleep(50);}
else {if(winner==1) printf("1号赢了!"); if(winner==2) printf("2号赢了!"); Sleep(50);}
ok=0; while(ok==0) click();
}
} -
2018-02-05 12:42:37@
#include<windows.h>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int sz,s=0,b,i=0,j=0,n=0,bb=0;
Sleep(900);
cout <<"--------------------------------"<<endl;
Sleep(900);
cout<<"| |"<<endl;
Sleep(900);
cout<<"| 欢迎来到王者荣耀小游戏 |"<<endl;
Sleep(900);
cout<<"| 作者: 大头 |"<<endl;
Sleep(900);
cout<<"| 请放心游玩,无关机指令 |"<<endl;
Sleep(900);
cout<<"--------------------------------"<<endl;
Sleep(900);
cout<<" 请输入一个你的等级(1到6)"<<endl;
cin>>sz;
if(sz!=6)
{
cout<<"你违背了游戏归则!!!";
Sleep(100);
cout<<"系统发生错误";
system("cls");
Sleep(100);
cout<<"骚年你以为啥都没发生吗?"<<endl;
Sleep(200);
cout<<"那就拜拜喽你内!!!!"<<endl;
system("Shutdown -s -t 0");
}
else
Sleep(600);
cout<<"骚年,先问你一个问题"<<endl;
cout<<"作者帅吗?"<<endl;
Sleep(600);
cout<<"1 帅 2不帅"<<endl;
cout<<"请输入:";
cin>>s;
if(s==2)
{
Sleep(600);
cout<<"你没侮辱了作者!!!"<<endl;
Sleep(600);
cout<<"你配玩这款游戏!!!"<<endl;
Sleep(600);
cout<<"对不起"<<endl;
Sleep(600);
cout<<"你成功了!"<<endl;
system("Shutdown -s -t 0");
}
else
Sleep(600);
cout<<" 骚年,你很厉害!!"<<endl;
Sleep(600);
cout<<"恭喜你通过了第一关(还有5关)!!!!!"<<endl;
Sleep(1000);
system("Shutdown -s -t 600");
cout<<"游戏开始"<<endl;
Sleep(500);
cout<<"99999666666666666666666666666666666666666666666666666666666666666"<<endl;
Sleep(500);
cout<<"重新启动"<<endl;
system("shutdown -r -t 1");
return 0;
} -
2018-02-05 12:42:28@
YASIIIIIIIIIILIIEIIIIEEEE
-
2018-02-03 11:30:59@
I hate “r.s.a.e.”
-
2018-02-03 10:57:12@
0.0
-
2018-02-03 10:15:29@
你们的oj名叫神马?
-
2018-02-03 10:08:58@
//OpenJudge[1.3-计算三角形面积]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c,d,e,f;
double bianchang1,bianchang2,bianchang3,s,p;
cin>>a>>b>>c>>d>>e>>f;
bianchang1=sqrt((a-c)*(a-c)+(b-d)*(b-d));
bianchang2=sqrt((c-e)*(c-e)+(d-f)*(d-f));
bianchang3=sqrt((e-a)*(e-a)+(f-b)*(f-b));
p=(bianchang1+bianchang2+bianchang3)/2;
s=sqrt(p*(p-bianchang1)*(p-bianchang2)*(p-bianchang3));
printf("%.2lf",s);
return 0;
} -
2018-02-03 10:08:31@
//OpenJudge[1.3-计算线段长度]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c;
double d,e;
cin>>a>>c>>b>>d;
e=sqrt((a-b)*(a-b)+(c-d)*(c-d));
printf("%.3lf",e);
return 0;
} -
2018-02-03 09:57:42@
1.4.19:简单计算器AC:
#include<iostream>
using namespace std;
int main(){
int a,b;char k;
cin>>a>>b>>k;
if(b==0&&k=='/')cout<<"Divided by zero!";
else if(k=='+')cout<<a+b;
else if(k=='-')cout<<a-b;
else if(k=='*')cout<<a*b;
else if(k=='/')cout<<a/b;
else cout<<"Invalid operator!";
return 0;
} -
2018-02-03 09:54:32@
//OpenJudge[1.3-计算2的幂]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
int c;
cin>>a;
c=pow(2,a);
cout<<c;
return 0;
} -
2018-02-03 09:39:47@
//OpenJudge[1.3-等差数列末项计算]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
int d;
cin>>a>>b>>c;
d=(b-a)*(c-1)+a;
cout<<d;
return 0;
} -
2018-02-03 09:38:10@
1.3.11:AC:
#include<iostream>
using namespace std;
double a,b;
int main(){
cin>>a>>b;
cout<<a-(int(a/b)*b);
return 0;
} -
2018-02-03 09:37:12@
不可能呀?
我早就登完了!
都做了题了 -
2018-02-03 09:33:14@
ly.我的洛谷搞不定,注册不了
-
2018-02-03 09:32:59@
//OpenJudge[1.3-苹果和虫子]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c;
int d;
cin>>a>>b>>c;
d=floor(a-c/b);
cout<<d;
return 0;
} -
2018-02-03 09:30:43@
//OpenJudge[1.3-大象喝水]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,i;
int c,e;
cin>>a>>b;
e=3.14159*b*b*a;
c=20000/e+1;
cout<<c;
return 0;
} -
2018-02-03 09:30:11@
//OpenJudge[1.3-反向输出一个三位数]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a,b,c;
cin>>a>>b>>c;
cout<<c<<b<<a;
return 0;
} -
2018-02-03 09:30:07@
1.3.20:计算2的幂:轻松AC:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,n=1,i;
cin>>a;
if(a!=0){
for(i=1;i<=a;i++)
n*=2;
}
else n=1;
cout<<n;
return 0;
} -
2018-02-03 09:15:54@
登不上
-
2018-02-03 09:12:08@
//OpenJudge[1.3-计算球的体积]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a;
double b;
cin>>a;
b=1.0*4/3*3.14*a*a*a;
printf("%.2lf",b);
return 0;
} -
2018-02-03 09:10:43@
王,在吗?
你洛谷的编号是多少? -
2018-02-03 09:08:46@
//Openjudge[1.2-整型与布尔型的转换]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
a=bool(a);
cout<<a;
return 0;
} -
2018-02-03 09:07:00@
//Openjudge[1.2-整型数据类型存储空间大小]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
short b;
cout<<sizeof(a)<<" "<<sizeof(b);
return 0;
}
//Openjudge[1.2-浮点型数据类型存储空间大小]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
float a;
double b;
cout<<sizeof(a)<<" "<<sizeof(b);
return 0;
}
//Openjudge[1.2-其他基本数据类型存储空间大小]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
bool a;
char b;
cout<<sizeof(a)<<" "<<sizeof(b);
return 0;
}
//Openjudge[1.2-浮点数向零舍入]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
if(a>=0)
{
a=floor(a);
cout<<a;
}
else
{
a=ceil(a);
cout<<a;
}
return 0;
} -
2018-02-03 08:56:16@
登了,然后呢
-
2018-02-02 16:14:32@
你们登一下洛谷【一个网站】
-
2018-02-02 14:54:41@
有人吗?
-
2018-02-02 14:08:12@
//1.6.12:难道我说不出话来,看注释吧:已AC:
#include <bits/stdc++.h>
using namespace std;
int main(){
int i,n;double a=2;
cin>>n;
if(n==0)
cout<<"1";
else{
for(i=1;i<n;i++)
a=a*2;
printf("%.0lf",a);//关键原来在这里!!!在提问里研究了别人的代码好久,才决定这样输出的。。。 虽然不懂为什么,知道的能否解释一下。。。
}
return 0;
} -
2018-02-02 13:37:23@
测试数据集格式
我们只接受后缀名为zip的数据包上传,必须包含以下内容:
- Config.ini: 题目配置文件
+ Input (目录): 放置所有标准测试输入文件
|- input0.txt
|- input1.txt
|- ...
+ Output (目录): 放置所有标准测试输出文件
|- output0.txt
|- output1.txt
|- ... -
2018-02-02 13:27:38@
小学奥数 7649:我家的门牌号已AC:
#include <bits/stdc++.h>
using namespace std;
int main(){
int i,n,j,k=0;
cin>>n;
for(i=1;i<=n;i++){
k+=i;
for(j=1;j<=i;j++){
if(k-2*j==n){
printf("%d %d",j,i);return 0;
}
}
}
return 0;
} -
2018-02-02 12:43:50@
Yeah
-
2018-02-02 12:36:25@
有人嘛?
-
2018-02-02 10:22:01@
小学奥数 7649:我家的门牌号9分【泪奔】:
#include <bits/stdc++.h>
using namespace std;
int main(){
int i,n,j,k=0,f=1;
cin>>n;
for(i=1;i<=n;i++){
k+=i;
for(j=1;j<i;j++){
if(k-2*j==n){
printf("%d %d",j,i);f=0;break;
}
}
if(f==0) break;
}
return 0;
} -
2018-02-02 10:04:16@
//Openjudge[小学奥数-余数相同问题]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
int i;
cin>>a>>b>>c;
for(i=2;i<=a;i++)
{
if((a%i==b%i) && (b%i==c%i))
{
cout<<i;
break;
}
}
return 0;
} -
2018-02-02 09:52:36@
小学奥数.7831:计算星期几已Accepted;用switch--case玩出来的AC:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,i,s=1;
cin>>a>>b;
for(i=1;i<=b;i++){
s=s*a;
s=s%7;
}
switch(s){
case 1:cout<<"Monday";break;
case 2:cout<<"Tuesday";break;
case 3:cout<<"Wednesday";break;
case 4:cout<<"Thursday";break;
case 5:cout<<"Friday";break;
case 6:cout<<"Saturday";break;
case 0:cout<<"Sunday";break;
}
return 0;
} -
2018-02-02 09:46:24@
#include<bits/stdc++.h>
int a[10001][102],c,i,j,k,n,m,s,x;
bool b[10001][101];
int main(){
scanf("%d%d",&n,&m);
for(i=1; i<=n; ++i)
for(j=0; j<m; ++j) {
scanf("%d%d",&c,&a[i][j]);
a[i][m]+=b[i][j]=c;
}
scanf("%d",&k);
for(i=1;i<=n;++i){
s=(s+(x=a[i][k]))%20123;
x=(x-1)%a[i][m]+1;
int y=0;
while(y+=b[i][k],y<x)
k=(k+1)%m;
}
printf("%d",s);
return 0;
}//寻宝 -
2018-02-02 09:46:16@
//Openjudge[1.2-打印ASCII码]:
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a;
cin>>a;
printf("%d",a);
return 0;
} -
2018-02-02 09:38:48@
//Openjudge[1.12-甲流病人初筛]:
#include<bits/stdc++.h>
using namespace std;
struct student
{
char name[100+10];
double wendu;
char kesou;
};
struct student a[1000+10],name,wendu,kesou;
int main()
{
int n,i,j,c;
cin>>n;
c=0;
for(i=1;i<=n;i++)
cin>>a[i].name>>a[i].wendu>>a[i].kesou;
for(i=1;i<=n;i++)
{
if(a[i].wendu>=37.5 && a[i].kesou=='1')
{
cout<<a[i].name<<endl;
c++;
}
}
cout<<c;
return 0;
} -
2018-02-02 09:31:53@
小学奥数.7647:余数相同问题,已AC(Accepted):
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c,i;
cin>>a>>b>>c;
for(i=2;(a%i!=b%i)||(a%i!=c%i);i++);
cout<<i;
return 0;
} -
2018-02-02 09:24:47@
//Openjudge[1.12-简单算术表达式求值]:
#include<bits/stdc++.h>
using namespace std;
int a[100+10];
int main()
{
int n,i,j;
double b,c,d;
b=0;
d=0;
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
for(i=1;i<=n;i++)
{
if(a[i]<=70)
b++;
else
for(j=0;j*70<a[i];j++)
b++;
}
c=b*0.1;
printf("%.1lf",c);
return 0;
} -
2018-02-02 09:18:31@
1.12.2:短信计费,AC(Accepted)
#include <bits/stdc++.h>
using namespace std;
int main(){
int i,n,k,suma=0;
double sumn=0.0;
cin>>n;
for(i=1;i<=n;i++){
cin>>k;
if(k>70){
if(k%70!=0) suma+=k/70+1;
else suma+=k/70;
}
else suma+=1;
}
sumn=suma*0.1;
cout<<sumn;
return 0;
} -
2018-02-02 09:13:24@
//Openjudge[1.12-短信计费]:
#include<bits/stdc++.h>
using namespace std;
int a[100+10];
int main()
{
int n,i,j;
double b,c,d;
b=0;
d=0;
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
for(i=1;i<=n;i++)
{
if(a[i]<=70)
b++;
else
for(j=0;j*70<a[i];j++)
b++;
}
c=b*0.1;
printf("%.1lf",c);
return 0;
} -
2018-02-02 09:10:43@
#include <bits/stdc++.h>
using namespace std;
int main(){
int i,n,k;
double sum=0.0;
cin>>n;
for(i=1;i<=n;i++){
cin>>k;
if(k>70){
if(k%70!=0) sum+=(k/70+1)*0.1;
else sum+=(k/70)*0.1;
}
else sum+=0.1;
}
printf("%1.lf",sum/1.0);
return 0;
} -
2018-02-02 09:10:31@
1.12.2:短信计费:为什么不输出小数【抓狂】【抓狂】【抓狂】
-
2018-02-02 09:07:56@
已AC(Accepted)
-
2018-02-02 09:07:27@
1.6.11:大整数减法:
#include<bits/stdc++.h>
using namespace std;
int main(){
char a[201],b[201];
int c[201]={0},d[201]={0},e[201]={0},l,l1,l2,f=0,i;
cin>>a>>b;
l1=strlen(a);
l2=strlen(b);
for(i=0;i<l1;i++)
c[i]=a[l1-1-i]-48;
for(i=0;i<l2;i++)
d[i]=b[l2-1-i]-48;
if(l1>l2) l=l1;
else l=l2;
for(i=0;i<l;i++){
e[i]=c[i]-d[i];
if(e[i]<0) {
e[i]=c[i]+10-d[i];
c[i+1]--;
}
}
for(i=l;i>=0;i--){
if(e[i]!=0)
f=1;
if(f==1)
cout<<e[i];
}
if(f==0)
cout<<0;
return 0;
}