首页
题库
公司真题
专项练习
面试题库
在线编程
面试
面试经验
AI 模拟面试
简历
求职
学习
基础学习课
实战项目课
求职辅导课
专栏&文章
竞赛
我要招人
发布职位
发布职位、邀约牛人
更多企业解决方案
AI面试、笔试、校招、雇品
HR免费试用AI面试
最新面试提效必备
登录
/
注册
~Marienbader
获赞
789
粉丝
3
关注
0
看过 TA
14
女
河海大学
2020
Java
IP属地:山东
暂未填写个人简介
私信
关注
拉黑
举报
举报
确定要拉黑~Marienbader吗?
发布(24)
评论
刷题
收藏
~Marienbader
关注TA,不错过内容更新
关注
2020-02-10 21:03
河海大学 Java
字符串栈
给过了,但是最后输出的时候,最后一个后面应该没有空格?但是牛客网给过了,emm #include<iostream> #include<stack> //还是用字符串栈了! using namespace std; int main() { string str; stack<string> s; while(cin>>str) //cin遇到空格则停止 { s.push(str); } while(!s.empty()) { cout<<s.top()<<' '; s.pop(); } return 0; }
moon2008:
你这个程序能跑就有鬼了。。没有string头文件,没有终止标志 根本不会有输出
0
点赞
评论
收藏
分享
2020-02-10 20:47
河海大学 Java
reverse函数
#include<iostream> #include<string> #include<algorithm> using namespace std; int main() { string str; cin>>str; reverse(str.begin(),str.end()); cout<<str<<endl; return 0; }
0
点赞
评论
收藏
分享
2020-02-10 20:39
河海大学 Java
转为string 做
#include<iostream> #include<string> #include<algorithm> using namespace std; int main() { string str; int a; cin>>a; str=to_string(a); reverse(str.begin(),str.end()); cout<<str<<endl; return 0; }
0
点赞
评论
收藏
分享
2020-02-10 20:30
河海大学 Java
cpp
#include<iostream> #include<string> using namespace std; int main() { //不同字符的个数,所以要去重!!! string str; getline(cin,str); int flag[130]={0}; int count=0; for(int i=0;i<str.size();i++) { if(str[i]>=0&&str[i]<=127) //是 { if(!flag[str[i]]) { flag[str[i]]=1; count++; } } } cout...
0
点赞
评论
收藏
分享
2020-02-10 20:01
河海大学 Java
cpp #int转string用string的+合成最后输出,注意处理多组测试用例,!temp%10的位置顺序
#include<iostream> #include<string> using namespace std; int main() { int arr[11]; int a; string str; int temp=0; while(cin>>a) { for(int i=0;i<11;i++) { arr[i]=-1; } temp=a%10; while(temp!=0) { if(arr[temp]==-1)//第一次出现 { arr[temp]=1; str+=to_string(temp); } a=a/10; temp=a%10; }...
0
点赞
评论
收藏
分享
2020-02-10 16:57
河海大学 Java
cpp不需要每个元素都换行
就是找输入数的质因子,不用判断素数啥的 #include<iostream> using namespace std; int main() { long a; while(cin>>a) { while(a!=1) { for(int i=2;i<=a;i++) { if(a%i==0) { //第一遍错误原因是不需要换行!!!!! cout<<i<<' '; //2有很多哥,不能直接就i++变成3 a=a/i; break; } } } } return 0; }
0
点赞
评论
收藏
分享
2020-02-10 16:11
河海大学 Java
cpp解法使用append和substr的两种用法
注意:不足8个和14个剩余6个,是相同子问题 #include<iostream> #include<string> using namespace std; int main() { string str; int less=0; while(cin>>str) { int left=str.size()%8; while(str.size()>=8) { cout<<str.substr(0,8)<<endl; str=str.substr(8); } if(left) { less=8-left; str.append(l...
0
点赞
评论
收藏
分享
2020-02-10 15:23
河海大学 Java
c++解法:注意清除上一组数据影响
#include<iostream> #include<set> using namespace std; int main() { int N,n; set<int> ss; while(cin>>N) //多组数据 { ss.clear(); //清除上一组数据的影响 while(N--) { cin>>n; ss.insert(n); } for (set<int>::iterator it = ss.begin(); it != ss.end(); it++) { cout << *it <<...
山火水:
set的属性就是值唯一且自动排序,相比起vector省略掉了重新写去重和排序函数的费时操作
0
点赞
评论
收藏
分享
2020-02-10 15:05
河海大学 Java
c++
#include<iostream> #include<string> using namespace std; //!!!不区分大小写,所以进行ascll码+32一样也++ int main() { string str; char s; int count=0; cin>>str; cin>>s; for(int i=0;i<str.size();i++) { if(str[i]==s) { count++; } else if(str[i]+32==s) { count++; } } cout<<count<<...
西红柿炒鸡蛋鸡蛋:
如果输入的字符串中有数字,数字的ascII码是要比英文字母小的,如果数字的ascII码加32之后可能就变成了英文字母,恰好你的目标字符是这个英文字母,就会出现误判。
0
点赞
评论
收藏
分享
1
2
创作者周榜
更多
关注他的用户也关注了:
牛客网
牛客网在线编程
牛客网题解
牛客企业服务