1003. 我要通过!(20)
来源:互联网 发布:淘宝提前收款怎么用 编辑:程序博客网 时间:2024/04/26 15:29
题目:http://www.patest.cn/contests/pat-b-practise/1003
代码:
#include <stdio.h>#include <string.h>int main(){ char a[10][100]; int n,i,j,k; //pnum,tnum是p和t的个数,bunm_A为p之前A的个数,mnum_A为p与t之间A的个数,anum_A为t之后A的个数 int pnum,tnum,bnum_A,mnum_A,anum_A; int pi,ti; scanf("%d",&n); for (i=0;i<n;i++) scanf("%s",a[i]); for (i=0;i<n;i++) { j = 0; pnum = 0; tnum = 0; k = 0; while( a[i][j]!='\0') { if ( a[i][j]!='P'&&a[i][j]!='A'&&a[i][j]!='T') { k = 1; break; } else if ( a[i][j]=='P') { pnum++; pi = j; } else if ( a[i][j]=='T') { tnum++; ti = j; } j++; } if (pnum!=1||tnum!=1||k == 1) printf("NO\n"); else { bnum_A = pi; mnum_A = ti-pi-1; anum_A = j-ti-1; //PT的情况 if ((ti-pi)==1) printf("NO\n"); //判断条件为符合条件的规律 else if (bnum_A*mnum_A==anum_A) printf("YES\n"); else printf("NO\n"); } } return 0;}
0 0
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- 1003. 我要通过!(20)
- wokao
- 个人笔记 html 04 提交表单与跳转页面冲突时
- 23种设计模式(3):抽象工厂模式
- 【差分约束】BZOJ 2330: [SCOI2011]糖果
- 动态调用DLL时不能加载依赖的程序集
- 1003. 我要通过!(20)
- Kinect视觉SLAM技术介绍
- 面试笔试杂项积累-leetcode 76-80
- CodeForces 543B Destroying Roads(最短路BFS)
- java数据库编程——执行SQL 语句
- CentOS下安装python-mysqldb
- 网络流 最大流 ISAP算法
- 后PPT时代
- C++ 通用编程