跟答案一模一样 1-9都试了怎么是零分

P5725 【深基4.习8】求三角形

你最好把cnt定义一下,这个出错应该是cnt编译出错了,给他赋值完就可以了,或者在主函数外面定义一下 ```cpp #include<bits/stdc++.h> using namespace std; int n,i,j,cnt; int main() { cin>>n; for(j=1;j<=n*n;j++) { if(j<10) cout<<0<<j; else cout<<j; if(!(j%n)) cout<<endl; } cout<<endl; i=2*n; while(i>0) { if(i>0) i-=2; for(j=0;j<i;j++) cout<<" "; for(j=0;j<(2*n-i)/2;j++) { cnt++; if(cnt<10)cout<<0<<cnt; else cout<<cnt; } cout<<endl; } return 0; } ```
by mmolmmol @ 2022-01-17 14:11:57


或者直接cnt=0就行 看自己喜好
by mmolmmol @ 2022-01-17 14:13:47


|