Information
- ID
- 715
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- (None)
- # Submissions
- 75
- Accepted
- 29
- Uploaded By
#include<iostream>
using namespace std;
int main() {
int n;
char q = 'A';
cin >> n;
for (int i = 0; i <= n; i++) {
for (int j = 1; j <= i; j++) {
cout << q;
q = q + 1;
if (q > 'Z') {
q = 'A';
}
}
cout << endl;
}
return 0;
}
第一层循环i应该从1开始吧,
#include <bits/stdc++.h>
using namespace std;
int n;
char l='A';
int main(){
cin>>n;
int cnt=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
if(l>'Z'){
l='A';
}
cout<<l;
l=l+1;
}
cout<<endl;
}
return 0;
}
反正我这么做AC了
By signing up a Hydro universal account, you can submit code and join discussions in all online judging services provided by us.