Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:这道题不就是这样子的吗,怎么会错,来看一下

Posted by pillar at 2006-07-12 17:20:05 on Problem 2612
In Reply To:这道题不就是这样子的吗,怎么会错,来看一下 Posted by:hahaxiao at 2005-09-16 16:01:08
> #include <iostream>
> using namespace std;
> char a[12][12];
> char b[12][12];
> int main() {
>     int i,j;
>     int n,k;
>     int c;
>     while(cin>>n) {
>         cin.ignore();
>         for(k=0;k<n;k++){
>             cin.getline(a[k],11);
>         }
>         for(k=0;k<n;k++) {
>             cin.getline(b[k],11);
>         }
>         for(i=0;i<n;i++) {
>             for(j=0;j<n;j++){
>                 if(b[i][j]=='.') {
>                     cout<<'.';
>                     continue;
>                 }    
>                 if(a[i][j]!='.'){
>                     cout<<a[i][j];
>                     continue;
>                 }   
>                 c=0;
>                 if(i-1>=0 && a[i-1][j]=='*') ++c;
>                 if(i+1<n && a[i+1][j]=='*') ++c;
>                 if(j-1>=0 && a[i][j-1]=='*') ++c;
>                 if(j+1<n && a[i][j+1]=='*' )++c;
>                 if(i-1>=0 && j-1>=0 && a[i-1][j-1]=='*') ++c;
>                 if(i-1>=0 && j+1<n && a[i-1][j+1]=='*') ++c;
>                 if(i+1<n && j-1>=0 && a[i+1][j-1]=='*') ++c;
>                 if(i+1<n && j+1<n &&a[i+1][j+1]=='*') ++c;
>                 cout<<c;   
>             }
>             cout<<endl;
>         }
>     }
>     return 0;
> }                
>        

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator