当前位置:网站首页>C语言 我要通过
C语言 我要通过
2022-06-30 01:25:00 【Martin の Blog】

算法设计思路
- 首先,输入的样例中如果有除了PAT其余的字符,程序视为NO
- 其次,对于 “aPbATca” 当 ‘c’ 和 ‘a’ 均为空字符,‘b’ 是 ‘A’ 字符,则可以判断:“PAAT” 是正确的
- 最后 ,其余的字符判断可以进行公式推论:P前面A的数量 * P和T中间A的数量 = T之后A的数量,如果满足这个公式也是对的
- 结合上诉思路开始代码的实现
代码
#include <stdio.h>
int main(){
char a[10][100] = {
0};
int n,i,j,count_A,count_P,count_T,s1,s2,s3;
scanf("%d", &n);
for(i=0; i<n; i++){
scanf("%s", &a[i]);
}
for(i=0; i<n; i++){
j=0, count_A=0, count_P=0, count_T=0, s1=0, s2=0, s3=0;
while(a[i][j] != '\0'){
if(a[i][j]=='A'){
count_A++;
}else if(a[i][j]=='P'){
count_P++;
s1 = j;
}else if(a[i][j]=='T'){
count_T++;
s2 = j;
}else{
s3 = 1;
break;
}
j++;
}
if(s3!=1 && count_P==1 && count_T==1 && !((s2-s1-1)*s1-(count_A-s2+1)) && (s2-s1-1)){
printf("YES");
}else{
printf("NO");
}
if(i != n-1){
printf("\n");
}
}
return 0;
}
运行结果

边栏推荐
- Cookie加密10
- MySQL function
- Mysql 监控2
- How to refuse the useless final review? Ape tutoring: it is important to find a suitable review method
- What if you can't write your composition well? Ape counseling: parents should pay attention to these points
- postman 之接口关联
- 2020-12-03
- Sentinel source code analysis Part 6 - sentinel adapter module Chapter 4 zuul2 gateway
- Online text digit recognition list summation tool
- Taguchi experimental method
猜你喜欢

Embedded exit (review and release)

3-6sql injection website instance step 5: break through the background to obtain web administrator permissions
![[recommended] how to quickly locate a bug during testing](/img/7a/726b2ea02ac5feb40e7378ba49e060.jpg)
[recommended] how to quickly locate a bug during testing

cookie加密9

Seata and the three platforms are working together in the summer of programming. Millions of bonuses are waiting for you

Transaction summary on June 25, 2022

第八届“互联网+”大赛 | 云原生赛道邀你来挑战

画画水族馆的应用特色及功能

Cookie加密13

STC89C52 single chip microcomputer simple calculator design and code demonstration
随机推荐
Varnish 基础概览6
Internal class usage scenarios, syntax and principle explanations
Varnish 基础概览1
一文读懂,MES管理系统模块功能
Interview summary
81. 搜索旋转排序数组 II
Three text to speech artifacts, each of which is very practical
Wechat applet - requestsubscribemessage:fail can only be invoked by user tap gesture
[three.js] Web3D first experience
【论文写作】英文论文写作指南
What is digital garbage? Follow the world's first AI artist to explore meta carbon Art
首届技术播客月开播在即
post请求出现WebKitFormBoundaryk的解决办法
Machine learning notes: time series decomposition STL
Seata 与三大平台携手编程之夏,百万奖金等你来拿
Analysis of IM instant messaging development technology on modern web
Mysql 监控1
英伟达Jetson Nano的初步了解
【PyTorch实战】生成对抗网络GAN:生成动漫人物头像
Visual studio 2017 cannot open the include file: 'qopenglfunctions_3_3_core': no such file or directory