
C++编程
cvMat
这个作者很懒,什么都没留下…
展开
-
质数与完全平方数的判断
质数bool isprime(int a){ for(int i=2;i<=sqrt(a);i++) if(a%i==0) return false; return true;} 完全平方数个数int nums_perfect_square(int n){ int ans=0; for(int原创 2016-09-11 22:02:58 · 1869 阅读 · 0 评论 -
C/C++读写文本文件、二进制文件[转]
参考连接:https://blog.youkuaiyun.com/nichengwuxiao/article/details/78789225#include <stdio.h> //包含c文件读写#include <fstream> //包含c++文件读写#include <iostream>#include <vector>#include <...转载 2019-01-08 11:08:12 · 3424 阅读 · 0 评论 -
Windows下为 Eclipse 配置 C/C++ 编译环境
参考连接:https://www.zybuluo.com/ghostfn1/note/303921转载 2018-07-05 14:07:00 · 455 阅读 · 0 评论 -
C++ fatal error LNK1104
问题:1>LINK : fatal error LNK1104: 无法打开文件“F:\新建文件夹\Visual Studio 2010\Projects\指针\Debug\指针.exe”解决方案:经过几天的摸索,终于找到方法了,这问题是我前几天就遇到了,一直没解决,有同样情况的童鞋只要打开任务管理器,然后结束提示中的最后一个程序就行了像我的就是 指针.exe 然后再编译一次就能转载 2016-12-18 09:51:09 · 1261 阅读 · 0 评论 -
C++ std_pair用法
#include #include #include using namespace std;int main () { pair string,double> product1 ("tomatoes",3.25); pair string,double> product2; pair string,double> product3; product2.first =原创 2016-12-18 09:50:38 · 479 阅读 · 0 评论 -
C++ 类的使用
#include #define OK 1using namespace std;class Tree{public: Tree(int Ages){ ages = Ages;} ~Tree(){} void grow(int years){ ages+=years;} void age();private: int ages;};void原创 2016-12-18 09:49:50 · 768 阅读 · 0 评论 -
C++ 类的相关语法,符号:和::的用法
#include #include using namespace std;//class 派生类名 : 继承方式 基类名//声明了一个类C,类C里声明了一个成员函数void F(),//但没有在类的声明里给出F()的定义,那么在类外定义F()时,//就要写成void C::F(),表示这个F()函数是类A的成员函数。class Point{private: int原创 2016-12-18 09:49:08 · 7908 阅读 · 0 评论 -
按要求分解字符串,输入两个数M,N;M代表输入的M串字符串,N代表输出的每串字符串的位数,不够补0。例如:输入2,8, “abc” ,“123456789”,则输出为“abc00000”,“12345
按要求分解字符串,输入两个数M,N;M代表输入的M串字符串,N代表输出的每串字符串的位数,不够补0。例如:输入2,8, “abc” ,“123456789”,则输出为“abc00000”,“12345678“,”90000000”#include <iostream>#include "string"using namespace std;void main(){ int m,n;原创 2016-09-07 14:42:11 · 2547 阅读 · 1 评论 -
求两个字符串公共子串的最长长度
输入:两个字符串,长度小于100 输出:两个字符串公共子串的最长长度 例: 输入: str1:asdgfghdsgfs str2:dasfdsgfse 输出:5 因为最长子串dsgfs的长度为5#include<iostream>#include"string"using namespace std;void main(){原创 2016-09-15 12:02:26 · 1189 阅读 · 0 评论 -
C++基础4:计算一字符串中出现频率最大的元素
#include <iostream>#include "string"#include <algorithm>using namespace std;void main(){ int rate[200] = {0};//储存频率 string str; cin>>str; for (int i = 0; i < str.length(); i++)原创 2016-09-03 10:03:23 · 690 阅读 · 0 评论 -
C++基础3:algorithm库的基础用法
#include <iostream>#include "string"#include <algorithm>//包含STL库提供的一些算法using namespace std;bool compare(int a,int b){ //return a<b; //升序排列,如果改为return a>b,则为降序 return a>b;}void main()原创 2016-09-02 17:13:13 · 723 阅读 · 0 评论 -
C++基础2
#include <iostream>#include "string"#include <sstream>using namespace std;void main(){ //将string转成int string str = "123"; int str_to_int = 0; str_to_int = atoi(str.c_str()); //将原创 2016-09-02 16:44:54 · 336 阅读 · 0 评论 -
机试题:过键盘输入100以内正整数的加、减运算式,请编写一个程序输出运算结果字符串。
问题描述:通过键盘输入100以内正整数的加、减运算式,请编写一个程序输出运算结果字符串。 输入字符串的格式为:“操作数1 运算符 操作数2”,“操作数”与“运算符”之间以一个空格隔开。 补充说明: 1. 操作数为正整数,不需要考虑计算结果溢出的情况。 2. 若输入算式格式错误,输出结果为“0”。 示例: 输入:“4 + 7” 输出:“11” 输入:“4 - 7”原创 2016-09-02 15:43:15 · 1291 阅读 · 0 评论 -
华为机试题:有10个整数,使前面格数顺序向后移m个位置,最后m个数变成最前面m个数。计算移动后的整数序列的前m个数和后m个数的和。
问题描述:有10个整数,使前面格数顺序向后移m个位置,最后m个数变成最前面m个数。计算移动后的整数序列的前m个数和后m个数的和。 运行时间限制: 无限制 内存限制: 无限制 输入: 先输入10个整数,以空格分隔; 再输入移动个数(即整数m) 输出: 移动后的整数序列 移动后的整数序列的前m个和后m个数的和。 样例输入: 1 2 3 4 5 6 7 8 9 10 3 样例输出原创 2016-09-02 13:18:49 · 1278 阅读 · 0 评论 -
C++基础1
#include<iostream>using namespace std;void main(){//A /*char array_char[100]; memset(array_char,0,sizeof(array_char));//利用memset初始化数组 memcpy(dst,rsc,size);//数组的直接copy */ /*******原创 2016-09-01 21:55:43 · 253 阅读 · 0 评论 -
C++函数指针数组
#include <iostream>//定义一个无返回值的指针函数类型hs,包含一个int型的参数typedef void (*hs)(int);using namespace std;void Sub_Print(int i){ cout<<(i-1)<<" ";}void Add_Print(int i){ cout<<(i+1)<<" ";}void Ju原创 2016-09-01 21:21:14 · 703 阅读 · 0 评论 -
华为机试题:输入两个超长整型构成的字符串,其间使用一个空格分隔,每个字符串最大长度为100个字符。求第一个整数除以第二个整数以后的余数。。
问题描述: 输入两个超长整型构成的字符串,其间使用一个空格分隔,每个字符串最大长度为100个字符。求第一个整数除以第二个整数以后的余数。。 运行时间限制: 无限制 内存限制: 无限制 输入: 输入两个以空格分隔的字符串,输入的每个字符串最大长度是100个字符。 输出: 输出为两个字符串相除以后的余数。如果结果异常,输出null 样例输入: 123456789 2原创 2016-09-01 21:16:46 · 1718 阅读 · 0 评论 -
C++实现explode
#include &lt;stdio.h&gt;#include &lt;iostream&gt;#include &lt;string&gt;#include &lt;vector&gt;using namespace std;const vector&lt;string&gt; explode(const string &转载 2019-01-08 16:19:45 · 925 阅读 · 1 评论