求回答,在线等,急!
查看原帖
求回答,在线等,急!
537668
song66楼主2022/3/4 19:33

为什么这段代码过不了? (+_+)?

#include<iostream>
using namespace std;
void sq(int r){
    for(int i=0;i<r;i++){
        for(int j=1;j<=r;j++){
            if(i*r+j < 10)cout<<0;
            cout<<i*r+j;
        }
        cout<<endl;
    }
}
void tr(int r){
    int k=1;
    for(int i=1;i<r;i++){
        for(int j=i;j<r;j++)cout<<"    ";
        for(int j=1;j<=i;j++){
            if(k < 10)cout<<0;
            cout<<k;
            k++;
        }
        cout<<endl;
    }
    for(int j=1;j<=r;j++){
        if(k < 10)cout<<0;
        cout<<k;
        k++;
    }
}
int main(){
    int n;
    cin>>n;
    sq(n);cout<<endl;tr(n);
    return 0;
}

代码应该没问题呀,大佬救救我!!!

2022/3/4 19:33
加载中...