社区讨论
感觉好多坑
P1042[NOIP 2003 普及组] 乒乓球参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @mdifkdz0
- 此快照首次捕获于
- 2025/07/25 14:18 7 个月前
- 此快照最后确认于
- 2025/07/25 14:33 7 个月前
我的第一个代码
CPP#include<iostream>
using std::string;using std::cin;using std::cout;
char a[10001][101],n;
int f[1000001];
int main(){
for(;;){
char a;
scanf("%c",&a);
if(a=='E') break;
if(a=='W') f[++n]=1;
if(a=='L') f[++n]=2;
}
int i=1;
while(1){
int A=0,B=0;
if(f[i]==0) break;
while(1){
if(A==11 || B==11) break;
if(f[i]==0) break;
if(f[i]==1) A++;
if(f[i++]==2) B++;
}
printf("%d:%d\n",A,B);
}
printf("\n");
i=1;
while(1){
int A=0,B=0;
if(f[i]==0) break;
while(1){
if(A==21 || B==21) break;
if(f[i]==0) break;
if(f[i]==1) A++;
if(f[i++]==2) B++;
}
printf("%d:%d\n",A,B);
}
}
赤橙黄绿青蓝紫
发现把
CPP发现把
if(A==11 || B==21) break;
要放后面
CPP#include<iostream>
using std::string;using std::cin;using std::cout;
char a[10001][101],n;
int f[1000001];
int main(){
for(;;){
char a;
scanf("%c",&a);
if(a=='E') break;
if(a=='W') f[++n]=1;
if(a=='L') f[++n]=2;
}
int i=1;
while(1){
int A=0,B=0;
while(1){
if(A==11 || B==11) break;
if(f[i]==0) break;
if(f[i]==1) A++;
if(f[i++]==2) B++;
}
printf("%d:%d\n",A,B);
if(f[i]==0) break;
}
printf("\n");
i=1;
while(1){
int A=0,B=0;
while(1){
if(A==21 || B==21) break;
if(f[i]==0) break;
if(f[i]==1) A++;
if(f[i++]==2) B++;
}
printf("%d:%d\n",A,B);
if(f[i]==0) break;
}
}
CPP#include<iostream>
using std::string;using std::cin;using std::cout;
int abs(int a){
if(a<0) return a*-1;
return a;
}
int n;
int f[1000001];
int main(){
for(;;){
char a;
scanf("%c",&a);
if(a=='E') break;
if(a=='W') f[++n]=1;
if(a=='L') f[++n]=2;
}
int i=1;
while(1){
int A=0,B=0;
while(1){
if((A==11 || B==11) && (abs(A-B)>1)) break;
if(f[i]==0) break;
if(f[i]==1) A++;
if(f[i++]==2) B++;
}
printf("%d:%d\n",A,B);
if(f[i]==0) break;
}
printf("\n");
i=1;
while(1){
int A=0,B=0;
while(1){
if((A==21 || B==21) && (abs(A-B)>1)) break;
if(f[i]==0) break;
if(f[i]==1) A++;
if(f[i++]==2) B++;
}
printf("%d:%d\n",A,B);
if(f[i]==0) break;
}
}
CPP#include<iostream>
using std::string;using std::cin;using std::cout;
int abs(int a){
if(a<0) return a*-1;
return a;
}
int n;
int f[1000001];
int main(){
char a;
for(;cin>>a;){
if(a=='E') break;
if(a=='W') f[++n]=1;
if(a=='L') f[++n]=2;
}
int i=1;
while(1){
int A=0,B=0;
while(1){
if((A>=11 || B>=11) && (abs(A-B)>1)) break;
if(f[i]==0) break;
if(f[i]==1) A++;
if(f[i++]==2) B++;
}
printf("%d:%d\n",A,B);
if(f[i]==0) break;
}
printf("\n");
i=1;
while(1){
int A=0,B=0;
while(1){
if((A>=21 || B>=21) && (abs(A-B)>1)) break;
if(f[i]==0) break;
if(f[i]==1) A++;
if(f[i++]==2) B++;
}
printf("%d:%d\n",A,B);
if(f[i]==0) break;
}
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...