PTA 乙级(1088,1081)
1081 检查密码 (15分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805261217153024
细节比较多,反正我改了几次才过
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 #include <algorithm> 5 #include <cstdio> 6 using namespace std; 7 int main() 8 { 9 int n; 10 int flag1,flag2,flag3,flag4; 11 string str; 12 cin>>n; 13 getchar(); 14 while(n--) 15 { 16 flag1=0,flag2=0,flag3=0,flag4=0; 17 getline(cin,str); 18 int len=str.length(); 19 if(len<6) 20 { 21 puts("Your password is tai duan le."); 22 continue; 23 } 24 else{ 25 for(int i=0;i<len;i++) 26 { 27 if(str[i]>='0'&&str[i]<='9') flag1=1; 28 else if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z')) flag2=1; 29 else if(str[i]=='.') flag3=1; 30 else flag4=1; 31 } 32 if(flag4) puts("Your password is tai luan le."); 33 else if(!flag1) puts("Your password needs shu zi."); 34 else if(!flag2) puts("Your password needs zi mu."); 35 else puts("Your password is wan mei."); 36 } 37 } 38 return 0; 39 }
1088 三人行 (20分)
https://pintia.cn/problem-sets/994805260223102976/problems/1038429286185074688
不要输出多余的空格以及丙不一定为整型
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstring> 5 #include <string> 6 using namespace std; 7 int main() 8 { 9 int m,x,y,flag=0; 10 int last_jia,last_yi; 11 double last_bin; 12 cin>>m>>x>>y; 13 int num1,num2,a,i; 14 for(i=10;i<100;i++) 15 { 16 int jia=i; 17 int yi=i%10*10+i/10; 18 if(yi*1.0/y==(abs(jia-yi)*1.0/x)) 19 { 20 flag=1; 21 last_yi=yi; 22 last_bin=yi*1.0/y; 23 last_jia=i; 24 } 25 } 26 if(flag==0) cout<<"No Solution"; 27 else{ 28 cout<<last_jia; 29 last_jia>m?(cout<<" Cong"):(last_jia==m?(cout<<" Ping"):(cout<<" Gai")); 30 last_yi>m?(cout<<" Cong"):(last_yi==m?(cout<<" Ping"):(cout<<" Gai")); 31 last_bin>m?(cout<<" Cong"):(last_bin==m?(cout<<" Ping"):(cout<<" Gai")); 32 } 33 return 0; 34 }
天晴了,起飞吧