![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
机试汇总
F-study
这个作者很懒,什么都没留下…
展开
-
面试上机(代码编写注意事项)
1。编写代码时要充分考虑边界条件,特殊输入(如nullptr,空字符串等),以及错误处理。原创 2018-09-05 10:16:58 · 1757 阅读 · 0 评论 -
华为机试(9)提取不重复的整数
#include<iostream>#include<string>using namespace std;int main(){ string str; //int a[10] = {0}; while(getline(cin, str)) { int a[10] = {0}; for(int ...原创 2018-09-07 14:58:56 · 221 阅读 · 1 评论 -
华为机试(8)合并表记录
map 使用::https://blog.csdn.net/shuzfan/article/details/53115922#include<iostream>#include<map>using namespace std;int main(){ int n; while(cin>> n) { ma...原创 2018-09-07 14:57:32 · 175 阅读 · 0 评论 -
华为机试(7)取近似值
#include<iostream>using namespace std;int fun(float a){ int aa = a + 0.5; return (int)aa;}int main(){ float a; cin >> a; int b = fun(a); cout<< b <...原创 2018-09-07 10:48:38 · 118 阅读 · 0 评论 -
华为机试(6)质数因子
#include&lt;iostream&gt;#include&lt;vector&gt;using namespace std;int main(){ unsigned long n; while(cin&gt;&gt; n) { if(n == 1) cout&lt;&lt; endl;原创 2018-09-07 10:39:04 · 155 阅读 · 0 评论 -
华为机试(5)进制转换
a 对应十进制 97 十六进制 61(A= a - 32 / 20) 0 48 30 #include<iostream>#include<string>using namespace std;int main(){ string str; while(getlin...原创 2018-09-07 10:23:57 · 247 阅读 · 0 评论 -
华为机试(3)字符串分隔
substr(string string, int a) ; 格式1: 1、string 需要截取的字符串 2、a 截取字符串的开始位置(注:当a等于0或1时,都是从第一位开始截取) 3、b 要截取的字符串的长度#include<iostream>#include<string>using name...原创 2018-09-07 09:23:16 · 134 阅读 · 0 评论 -
华为机试(3) 明明的随机数
C++ STL(标准模板库)是一套功能强大的 C++ 模板类,提供了通用的模板类和函数,这些模板类和函数可以实现多种流行和常用的算法和数据结构,如向量、链表、队列、栈。http://www.runoob.com/cplusplus/cpp-stl-tutorial.html类属性算法unique的作用是从输入序列中“删除”所有相邻的重复元素。 erase:得到一个不重复的序列#...原创 2018-09-06 17:11:09 · 225 阅读 · 0 评论 -
华为机试题(2):计算字符个数
大写变小写 + 32 ;#include<iostream>#include<string>using namespace std;int main(){ string str; char ch; int cnt = 0; getline(cin, str); ch = getchar(); for(in...原创 2018-09-06 16:13:31 · 148 阅读 · 0 评论 -
华为上机题(1)
思路: 1。 倒序查找 第一个字母的位置 ; 而后倒序统计该字母结尾的单词长度 2。 getline(cin, str);// 取一行字符串 str.size() // 求字符串长度#include<iostream>#include<string>using namespace std;int main(){ st...原创 2018-09-06 15:58:12 · 226 阅读 · 1 评论 -
华为机试(10)统计字符个数
数组解决;#include<iostream>using namespace std;int main(){ int arr[128] = {0}; int cnt = 0; char ch; while(cin>> ch) { if (ch >= 0 && ch <= 127...原创 2018-09-07 15:11:12 · 186 阅读 · 0 评论