标签:lse scanf ring include 位置 class turn char s str
#include<stdio.h> #include<string.h> int main(){ int n,i,j; int cntp=0,cntt=0,cnta=0,flag=1; char *p1,*p2; char *p3; scanf("%d",&n); char s[100][100]; for(i=0;i<n;++i) { scanf("%s",s[i]); } for(i=0;i<n;++i) { for(j=0;s[i][j]!=‘\0‘;j++) { if(s[i][j]==‘P‘) cntp++; else if(s[i][j]==‘A‘) cnta++; else if(s[i][j]==‘T‘) cntt++; else {flag=2; break;} } if(flag==1&&cntp==1&&cntt==1&&cnta!=0) { p1=strchr(s[i],‘P‘); p2=strchr(s[i],‘T‘); p3=strrchr(s[i],‘A‘); if((p1-s[i])*(p2-p1-1)==strlen(p2)-1) flag=0; } if(flag==0) puts("YES"); else puts("NO"); } printf("%d\n",p1); printf("%d\n",p2); printf("%d\n",s[i]); printf("%d\n",p3); printf("%d\n",strlen(p2)); return 0; }
输入一个P和T时返回值是字符串的位置,超过1个就不是
标签:lse scanf ring include 位置 class turn char s str
原文地址:https://www.cnblogs.com/chcodelife/p/11130215.html