牛客网PAT练习场-到底买不买
2024-09-07 05:46:21
题目地址:https://www.nowcoder.com/pat/6/problem/4065
题意:用数组统计好字符,最后进行相减,最后进行统计
/**
*
*作者:Ycute
*时间:2019-12-05-14.11.53
*题目题意简单描述:用数组统计好字符,最后进行相减,最后进行统计
*/ #include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std; int main(){
char temp[];
int flag[]={};
scanf("%s",temp);
for(int i=;i<strlen(temp);i++){
flag[temp[i]]++;
}
getchar();
scanf("%s",temp);
for(int i=;i<strlen(temp);i++){
flag[temp[i]]--;
}
int j=;//标记到底是缺还是盈
int sum=;
int sub=;
for(int i=;i<;i++){
if(flag[i]<){
j=;
sub-=flag[i]; }else{
sum+=flag[i];
}
}
if(j==){
printf("No %d\n",sub);
}else{
printf("Yes %d\n",sum);
}
return ;
}
最新文章
- [LeetCode] Range Sum Query - Mutable 区域和检索 - 可变
- (原) 2.1 Zookeeper原生API使用
- GUID 全局统一标识符的介绍
- CIImage实现滤镜效果
- WP7推送通知服务
- maven实战_01_搭建maven开发环境
- 【SVN】删除文件/文件夹 svn: E205007: Could not use external editor to fetch log message
- 十个最常见的Java字符串问题
- c#安全性、稳定性、高性能需要注重的点
- Font Awesome 4.0.3 字体图标完美兼容IE7
- 深入理解HTTP Session
- G1收集器-原创译文[未完成]
- c# 替换所有中文、标点符号,全角转半角
- STL - priority_queue(优先队列)
- web应用
- OpenGL中的常用绘图的命令与效果(经验设置)
- [NLP/Attention]关于attention机制在nlp中的应用总结
- IntelliJ IDEA 进行多线程调试
- Python学习笔记4-os,sys模块
- SharePoint 2013 升级