llllmz

导航

2024年1月18日

KY129 简单计算器C++

摘要: 、 这是目前阶段做的最难最吃力的题目。调试了一遍又一遍去看逻辑上出现的各种问题。。。 #include<iostream> #include<string> #include<stack> #include<map> using namespace std; int main(){ map<char 阅读全文

posted @ 2024-01-18 22:15 神奇的萝卜丝 阅读(38) 评论(0) 推荐(0)

1978:扩号匹配问题C

摘要: #include<stdio.h> int main(){ char s[101]; while(scanf("%s",s)!=EOF){ printf("%s\n",s); char tem[101]; int a[101]={0}; int top=0; int i=0; for(;s[i]!= 阅读全文

posted @ 2024-01-18 19:29 神奇的萝卜丝 阅读(26) 评论(0) 推荐(0)

1978:扩号匹配问题

摘要: 用一个vector来记录每个位置打印打印情况, 结果: 阅读全文

posted @ 2024-01-18 17:01 神奇的萝卜丝 阅读(59) 评论(0) 推荐(0)

20. 有效的括号C

摘要: 写个数组当作栈用就行了。 bool isValid(char* s) { int t[100000]={0}; int top=0; int flag=1; for(int i=0;i<strlen(s);i++){ if(s[i]=='('){ t[top++]=1; }else if(s[i]= 阅读全文

posted @ 2024-01-18 15:43 神奇的萝卜丝 阅读(21) 评论(0) 推荐(0)

20. 有效的括号C++

摘要: 括号匹配用栈是解决是最简单那的。 遇到左括号就入栈。遇到右括号就出栈,然后看是否匹配。这里再用一个map把括号数字化会更简单。 class Solution { public: bool isValid(string s) { map<char,int> m={ {'(',1},{')',-1}, 阅读全文

posted @ 2024-01-18 15:24 神奇的萝卜丝 阅读(29) 评论(0) 推荐(0)

KY109 Zero-complexity Transposition C

摘要: 用数组倒序输出就行了。 #include<stdio.h> #include<stdlib.h> int main(){ int n; while(scanf("%d",&n)!=EOF){ long* a=(long*)malloc(sizeof(long)*n); for(int i=0;i<n 阅读全文

posted @ 2024-01-18 14:44 神奇的萝卜丝 阅读(14) 评论(0) 推荐(0)

KY109 Zero-complexity TranspositionC++

摘要: h 很简单的题目,不管是用数组还是用栈都非常简单。 #include<iostream> #include<stack> using namespace std; int main(){ int n; while(cin >> n){ stack<long> s; while(n!=0){ int 阅读全文

posted @ 2024-01-18 14:40 神奇的萝卜丝 阅读(16) 评论(0) 推荐(0)