为什么C++和Python接近一样的代码一个AC一个RE啊
查看原帖
为什么C++和Python接近一样的代码一个AC一个RE啊
447648
蛋蛋工作室楼主2023/6/26 20:52

C++记录

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cctype>
#include<cstring>
using namespace std;
/*没有什么用的快读
inline int read()
{
    char c=getchar();
    int x=0,f=1;
    while(c > '9' || c < '0') {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c <= '9' && c >= '0')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
*/
int main() {
    long long a,b,f;
    char c;
    cin>>a>>b>>c>>f;
    for (int i=1;i<=a;i++){
        for (int j=1;j<=b;j++){
            if (i==1 || i==a)
                cout<<c;
            else if (j==1 || j==b)
                cout<<c;
            else {
                if (f)
                    cout<<c;
                else 
                    cout<<' ';
            }
        }
        cout<<endl;
    }
    return 0;
}

Python记录

代码:

d=str(input())
d=d.split(' ')
a=int(d[0])
b=int(d[1])
c=str(d[2])
f=int(d[3])
for i in range(0,a,1):
    for j in range(0,b,1):
        if(i==0 or i==a-1):
            print(c,end='')
        elif(j==0 or j==b-1):
            print(c,end='')
        else:
            if(f!=0):
                print(c,end='')
            else:
                print(' ',end='')
    print()
2023/6/26 20:52
加载中...