Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
帮忙看看 怎么是WA#include <iostream> using namespace std; int isMine(int l, int mimi[]){ for(int ww=0;ww<50;ww++){ if(mimi[ww]==l){ return 1; break; } } return 0; } int main(){ int n; cin>>n; int mine [50]; char c; int count=0; int index=0; while(count<n*n){ cin>>c; if(c=='*'){ mine[index++]=count; } count++; } count=0; int flag=0; char map[100]; while(count<n*n){ cin>>c; if(c=='x'){ if(isMine(count,mine) ){ map[count]='*'; flag=1; } else{ int mm[8]={count-(n-1),count-n,count-(n+1),count-1,count+1,count+n-1,count+n,count+n+1}; if(count%n==0){ mm[2]=-1; mm[3]=-1; mm[5]=-1; }else if(count%n==n-1) { mm[0]=-1; mm[4]=-1; mm[7]=-1; } int cMine=0; for(int i=0;i<8;i++){ for(int j=0;j<50;j++){ if(mm[i]==mine[j]) { cMine++; break; } } } map[count]=cMine+48; } }else{ map[count]='.'; } count++; } if(flag){ for(int qqq=0;qqq<50;qqq++){ if(mine[qqq]>=0&&mine[qqq]<n*n) map[mine[qqq]]='*'; } } for(int u=0;u<n*n;u++){ cout<<map[u]; if(u % n==n-1) cout<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator