ccf-201403-3有趣的命令行
2024-10-08 02:29:55
傻逼题,要是考试只能得0分。。
提供几组傻逼数据,这要是在真实的生活中一定是错的。。。
还是要好好读题吧,全凭自己的感觉就得0分
albw:x
4
ls -a docu
Case 1: -a
ls -w -w
Case 2: -w -w
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define pb(x) push_back(x)
#define cls(x, val) memset(x, val, sizeof(x))
#define fi first
#define se second
#define mp(x, y) make_pair(x, y)
#define inc(i, l, r) for(int i=l; i<=r; i++)
const int inf = 0x3f3f3f3f;
const int maxn = 2000+10;
bool have[maxn];
bool exist[maxn];
struct Node{
string s;
string var;
bool prin;
}node[26];
int n;
vector<string> split;
vector<string> process(char *s){
int st = 0;
vector<string> temp;
string t;
int len = strlen(s);
for(int i=0; i<len; i++){
if(s[i] == ' '){
t = "";
for(int j=st; j<i; j++){
t+=s[j];
}
temp.push_back(t);
st = i+1;
}
}
t = "";
for(int j=st; j<len; j++){
t+=s[j];
}
temp.push_back(t);
return temp;
}
int main(){
ios::sync_with_stdio(false);
char op[300];
scanf("%s", op);
int len = strlen(op);
for(int i=0; i<len; i++){
if(op[i]>='a'&&op[i]<='z'){
exist[op[i]-'a'] = true;
if(i+1<len && op[i+1] == ':'){
have[op[i]-'a'] = true;
i++;
}
}
}
int kase = 1;
scanf("%d", &n);
getchar();
while(n--){
gets(op);
for(int i=0; i<26; i++) node[i].prin = false;
split = process(op);
int sz = split.size();
// for(int i=0; i<sz; i++){
// printf("%s ", split[i].c_str());
// }
for(int i=1; i<sz; i++){
string temp = split[i];
if(temp[0] == '-'){
int c = temp[1]-'a';
if(!exist[c]) break;
if(have[c] == true){
if(i==sz-1) break;
else {
node[c].prin = true;
node[c].var = split[i+1];
}
i++;
}
else{
node[c].prin = true;
}
}
else break;
}
//cout<<"Case "<<kase++<<":";
printf("Case %d:", kase++);
for(int i=0; i<26; i++){
if(node[i].prin){
//cout<<" -"<<char(i+'a');
printf(" -%c", char(i+'a'));
if(have[i]){
//cout<<" "<<node[i].var;
printf(" %s", node[i].var.c_str());
}
}
}
printf("\n");
}
return 0;
}
最新文章
- 批量解密SQLSERVER数据库中的各种对象的工具dbForge SQL Decryptor
- Codeforces Round #384 (Div. 2)D-Chloe and pleasant prizes
- Facebook不相信所谓的员工能力等级。《长效商业英雄》(《哈佛商业评论》2016年11期),4星。
- mysql重点--正确使用
- MySQL导入.sql文件及常用命令
- Silverlight 限制 规则输入(正整数或小数)的另一种“技巧”写法
- Log4j 2.0在开发中的高级使用具体解释—配置简单的控制台输出(三)
- IO口输入输出模式理解
- ThinkPHP系统变量,常量,序列化,反序列化,缓存
- [js高手之路] javascript面向对象写法与应用
- 关于NIM博弈结论的证明
- Using $this when not in object context in
- Linux 每日命令行
- Djang之cookie和session
- node.js 使用 net 模块模拟 websocket 握手,进行数据传递。
- C# Chart使用总结 2 ----属性
- python 学习 面向对象编程
- scrapy 项目通过scrapyd部署
- golang实现kafka的消息推送
- Go语言中结构体的使用-第1部分结构体