题解

53 条题解

  • 0
    @ 2015-12-02 16:34:33

    program p1975;
    var a:array[0..105,0..105] of char;
    n,m,i,j,sum:longint;
    begin
    readln(n,m);
    for i:=1 to n do
    begin
    for j:=1 to m do
    read(a[i,j]);
    readln;
    end;
    for i:=1 to n do
    begin
    for j:=1 to m do
    if a[i,j]='*' then write('*')
    else
    begin
    sum:=0;
    if a[i-1,j-1]='*' then inc(sum);
    if a[i,j-1]='*' then inc(sum);
    if a[i+1,j-1]='*' then inc(sum);
    if a[i-1,j+1]='*' then inc(sum);
    if a[i-1,j]='*' then inc(sum);
    if a[i+1,j]='*' then inc(sum);
    if a[i,j+1]='*' then inc(sum);
    if a[i+1,j+1]='*' then inc(sum);
    write(sum);
    end;
    writeln;
    end;
    end.

  • 0
    @ 2015-11-17 17:18:28

    program mine;
    var
    a:array[0..150,0..150]of char;
    i,j,n,m:longint;

    procedure js;
    begin
    if a[i-1,j-1]='*' then inc(a[i,j]);
    if a[i-1,j]='*' then inc(a[i,j]);
    if a[i-1,j+1]='*' then inc(a[i,j]);
    if a[i,j-1]='*' then inc(a[i,j]);
    if a[i,j+1]='*' then inc(a[i,j]);
    if a[i+1,j-1]='*' then inc(a[i,j]);
    if a[i+1,j]='*' then inc(a[i,j]);
    if a[i+1,j+1]='*' then inc(a[i,j]);
    end;

    begin
    readln(n,m);
    for i:=1 to n do
    begin
    for j:=1 to m do
    read(a[i,j]);
    readln;
    end;
    for i:=1 to n do
    for j:=1 to m do
    if a[i,j]='?' then a[i,j]:='0';
    for i:=1 to n do
    for j:=1 to m do
    if a[i,j]<>'*' then js;
    for i:=1 to n do
    begin
    for j:=1 to m do
    write(a[i,j]);
    writeln;
    end;
    end.

  • 0
    @ 2015-11-11 20:10:18

    program mine;
    var a:array[0..101,0..101] of char;
    b:array[0..101,0..101] of integer;
    i,j,n,m:integer;
    begin
    for i:=0 to 101 do
    for j:=0 to 101 do
    a[i,j]:='?';
    readln(n,m);
    for i:=1 to n do
    begin
    for j:=1 to m do begin read(a[i,j]);b[i,j]:=0; end;
    readln;
    end;
    for i:=1 to n do
    for j:=1 to m do
    if a[i,j]='*' then
    begin
    b[i,j]:=-300;
    inc(b[i,j+1]);
    inc(b[i,j-1]);
    inc(b[i+1,j]);
    inc(b[i-1,j]);
    inc(b[i+1,j-1]);
    inc(b[i+1,j+1]);
    inc(b[i-1,j-1]);
    inc(b[i-1,j+1]);
    end;
    for i:=1 to n do
    begin
    for j:=1 to m do
    if b[i,j]<0 then write('*') else write(b[i,j]);
    writeln;
    end;
    end.

  • 0
    @ 2015-11-11 12:28:23

    #include <iostream>
    using namespace std;
    char a[101][101];
    char x[101][101];
    int msum(int x,int y)
    { char count='0';
    if(a[x+1][y]=='*') count+=1;
    if(a[x-1][y]=='*') count+=1;
    if(a[x][y+1]=='*') count+=1;
    if(a[x][y-1]=='*') count+=1;
    if(a[x+1][y+1]=='*') count+=1;
    if(a[x+1][y-1]=='*') count+=1;
    if(a[x-1][y+1]=='*') count+=1;
    if(a[x-1][y-1]=='*') count+=1;
    return count;
    }
    int main()
    {int b,c,d,e,f,g;
    cin>>b>>c;
    for(int i=1;i<=b;i++)
    for(int j=1;j<=c;j++)
    cin>>a[i][j];
    for(int i=1;i<=b;i++)
    for(int j=1;j<=c;j++)
    {if(a[i][j]=='*') x[i][j]='*';
    if(a[i][j]=='?') x[i][j]=msum(i,j);
    }
    for(int i=1;i<=b;i++)
    {for(int j=1;j<=c;j++)
    cout<<x[i][j];
    cout<<endl;
    }
    }

  • 0
    @ 2015-11-11 12:27:42

    #include <iostream>
    using namespace std;
    char a[101][101];
    char x[101][101];
    int msum(int x,int y)
    { char count='0';
    if(a[x+1][y]=='*') count+=1;
    if(a[x-1][y]=='*') count+=1;
    if(a[x][y+1]=='*') count+=1;
    if(a[x][y-1]=='*') count+=1;
    if(a[x+1][y+1]=='*') count+=1;
    if(a[x+1][y-1]=='*') count+=1;
    if(a[x-1][y+1]=='*') count+=1;
    if(a[x-1][y-1]=='*') count+=1;
    return count;
    }
    int main()
    {int b,c,d,e,f,g;
    cin>>b>>c;
    for(int i=1;i<=b;i++)
    for(int j=1;j<=c;j++)
    cin>>a[i][j];
    for(int i=1;i<=b;i++)
    for(int j=1;j<=c;j++)
    {if(a[i][j]=='*') x[i][j]='*';
    if(a[i][j]=='?') x[i][j]=msum(i,j);
    }
    for(int i=1;i<=b;i++)
    {for(int j=1;j<=c;j++)
    cout<<x[i][j];
    cout<<endl;
    }
    }

  • 0
    @ 2015-11-11 12:26:59

    #include <iostream>
    using namespace std;
    char a[101][101];
    char x[101][101];
    int msum(int x,int y)
    { char count='0';
    if(a[x+1][y]==__'*') count+=1;
    if(a[x-1][y]=='*') count+=1;
    if(a[x][y+1]=='*') count+=1;
    if(a[x][y-1]=='*') count+=1;
    if(a[x+1][y+1]=='*') count+=1;
    if(a[x+1][y-1]=='*') count+=1;
    if(a[x-1][y+1]=='*') count+=1;
    if(a[x-1][y-1]=='*') count+=1;
    return count;
    }
    int main()
    {int b,c,d,e,f,g;
    cin>>b>>c;
    for(int i=1;i<=b;i++)
    for(int j=1;j<=c;j++)
    cin>>a[i][j];
    for(int i=1;i<=b;i++)
    for(int j=1;j<=c;j++)
    {if(a[i][j]=='*') x[i][j]='*';
    if(a[i][j]=='?') x[i][j]=msum(i,j);
    }
    for(int i=1;i<=b;i++)
    {for(int j=1;j<=c;j++)
    cout<<x[i][j];
    cout<<endl;
    }
    }

  • 0
    @ 2015-11-11 12:21:42

    #include <iostream>

    using namespace std;
    char a[101][101];
    char x[101][101];
    int msum(int x,int y)
    { char count='0';
    if(a[x+1][y]=='*') count+=1;
    if(a[x-1][y]=='*') count+=1;
    if(a[x][y+1]=='*') count+=1;
    if(a[x][y-1]=='*') count+=1;
    if(a[x+1][y+1]=='*') count+=1;
    if(a[x+1][y-1]=='*') count+=1;
    if(a[x-1][y+1]=='*') count+=1;
    if(a[x-1][y-1]=='*') count+=1;
    return count;
    }
    int main()
    {int b,c,d,e,f,g;
    cin>>b>>c;
    for(int i=1;i<=b;i++)
    for(int j=1;j<=c;j++)
    cin>>a[i][j];
    for(int i=1;i<=b;i++)
    for(int j=1;j<=c;j++)
    {if(a[i][j]=='*') x[i][j]='*';
    if(a[i][j]=='?') x[i][j]=msum(i,j);
    }
    for(int i=1;i<=b;i++)
    {for(int j=1;j<=c;j++)
    cout<<x[i][j];
    cout<<endl;
    }
    }

  • 0
    @ 2015-11-11 12:21:34

    #

  • 0
    @ 2015-11-09 14:47:07

    如果用C++简直无脑模拟。。
    #include<iostream>
    using namespace std;

    char mx[105][105];
    int ans[105][105];
    int n,m;

    void work(int a,int b){
    int count=0;
    if(mx[a+1][b]=='*' && a+1<=n) count++;
    if(mx[a-1][b]=='*' && a-1<=n) count++;
    if(mx[a][b+1]=='*' && b+1<=m) count++;
    if(mx[a][b-1]=='*' && b-1<=m) count++;
    if(mx[a+1][b+1]=='*' && a+1<=n && b+1<=m) count++;
    if(mx[a+1][b-1]=='*' && a+1<=n && b-1<=m) count++;
    if(mx[a-1][b+1]=='*' && a-1<=n && b+1<=m) count++;
    if(mx[a-1][b-1]=='*' && a-1<=n && b-1<=m) count++;
    ans[a][b]=count;
    return;
    }

    int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
    cin>>mx[i][j];
    }
    }
    for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
    if(mx[i][j]=='?') work(i,j);
    }
    }
    for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
    if(mx[i][j]=='*') cout<<'*';
    else cout<<ans[i][j];
    if(j==m) cout<<endl;
    }
    }
    return 0;
    }
    (考试时源程序)

  • 0
    @ 2015-11-09 09:04:02

    简单的if语句判断
    如果你不知道字符char怎么读 (要读换行) 那你就。。。。
    var
    a:array[0..101,0..101] of char;
    ans,n,m,i,j:longint;
    begin
    readln(n,m);
    for i:=1 to n do
    begin
    for j:=1 to m do read(a[i,j]);
    readln;
    end;
    for i:=1 to n do
    begin
    for j:=1 to m do
    if a[i,j]='*' then write('*') else
    begin
    ans:=0;
    if a[i-1,j]='*' then inc(ans);
    if a[i+1,j]='*' then inc(ans);
    if a[i,j+1]='*' then inc(ans);
    if a[i,j-1]='*' then inc(ans);
    if a[i+1,j+1]='*' then inc(ans);
    if a[i+1,j-1]='*' then inc(ans);
    if a[i-1,j+1]='*' then inc(ans);
    if a[i-1,j-1]='*' then inc(ans);
    write(ans);
    end;
    writeln;
    end;
    end.

  • -1
    @ 2017-02-17 19:52:15

    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 564 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 564 KiB, score = 10
    测试数据 #2: Accepted, time = 15 ms, mem = 564 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 564 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 564 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 564 KiB, score = 10
    测试数据 #6: Accepted, time = 15 ms, mem = 564 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 564 KiB, score = 10
    测试数据 #8: Accepted, time = 15 ms, mem = 564 KiB, score = 10
    测试数据 #9: Accepted, time = 15 ms, mem = 564 KiB, score = 10
    Accepted, time = 60 ms, mem = 564 KiB, score = 100
    代码

    include <cstdio>

    include <cstring>

    using namespace std;
    int main()
    {
    int n=0,m=0;
    char leiqu[105][105]={0},geshu[105][105]={0};
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
    for(int j=0;j<m;j++)
    {
    scanf("%c",&leiqu[i][j]);
    if(leiqu[i][j]!='*'&&leiqu[i][j]!='?')
    {
    j--;
    }
    }
    }
    for(int i=0;i<n;i++)
    {
    for(int j=0;j<m;j++)
    {
    if(leiqu[i][j]=='*')
    {
    geshu[i][j]='*';
    }
    else
    {
    int num=0;
    for(int a=i-1;a<=i+1;a++)
    {
    for(int b=j-1;b<=j+1;b++)
    {
    if(leiqu[a][b]=='*'&&a>=0&&a<n&&b>=0&&b<m)
    {
    num++;
    }
    }
    }
    if(num==0)
    {
    geshu[i][j]='0';
    }
    else if(num==1)
    {
    geshu[i][j]='1';
    }
    else if(num==2)
    {
    geshu[i][j]='2';
    }
    else if(num==3)
    {
    geshu[i][j]='3';
    }
    else if(num==4)
    {
    geshu[i][j]='4';
    }
    else if(num==5)
    {
    geshu[i][j]='5';
    }
    else if(num==6)
    {
    geshu[i][j]='6';
    }
    else if(num==7)
    {
    geshu[i][j]='7';
    }
    else if(num==8)
    {
    geshu[i][j]='8';
    }
    num=0;
    }
    }
    }
    for(int i=0;i<n;i++)
    {
    for(int j=0;j<m;j++)
    {
    printf("%c",geshu[i][j]);
    }
    if(i!=n-1)
    {
    printf("\n");
    }
    }
    return 0;
    }

  • -1
    @ 2016-08-25 12:49:18

    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:39:08
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:39:02
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:58
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:55
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:54
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:52
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:50
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:48
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:46
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:44
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:42
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:38
    Waiting
    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:37
    Compiling

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:35
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:33
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:32
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:30
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:27
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:25
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:23
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:22
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:20
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:18
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:17
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:15
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:14
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:12
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:11
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:09
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:07
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:06
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:05
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:03
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:38:01
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:37:59
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:37:58
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:37:56
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:37:54
    Compile Error

    0
    0 0

    P1227 拯救世界-程序设计
    卡评测机专用账号 C++ 2016-08-25 12:37:52

  • -1
    @ 2016-08-25 12:45:37

    卧槽…………
    ```c++

    您递交的代码已经加入评测队列,请稍后……
    以下是排在您前面的评测请求:
    Waiting [您的评测请求]
    Waiting P1227   卡评测机专用账号   2016-08-25 12:39:08
    Waiting P1227   卡评测机专用账号   2016-08-25 12:39:02
    Waiting P1227   卡评测机专用账号   2016-08-25 12:38:58
    Waiting P1227   卡评测机专用账号   2016-08-25 12:38:55
    Waiting P1227   卡评测机专用账号   2016-08-25 12:38:54
    注:只列出了最近5个评测任务,实际任务数可能更多。
    

信息

ID
1975
难度
4
分类
模拟 点击显示
标签
递交数
2822
已通过
1091
通过率
39%
被复制
22
上传者