C++ vector基本用法

摘要: 转自金河http://www.cnblogs.com/wang7/archive/2012/04/27/2474138.html 1 基本操作 (1)头文件#include<vector>. (2)创建vector对象,vector<int> vec; (3)尾部插入数字:vec.push_back 阅读全文
posted @ 2017-05-31 00:00 那年月光 阅读(441) 评论(0) 推荐(0) 编辑

QT快捷键

摘要: 1.F5(笔记本下是win键加F5)和Ctrl+R都是运行。 2. 阅读全文
posted @ 2017-05-30 15:43 那年月光 阅读(172) 评论(0) 推荐(0) 编辑

malloc 和free例程

摘要: #include <stdio.h>#include <stdlib.h>int main(){int a;scanf("%d",&a);int *p=(int *)malloc(a*4);//注意:因为malloc是byte的,所以这里要乘以4,不然free的时候程序就会奔溃,因为使用的空间大于申 阅读全文
posted @ 2017-05-29 00:24 那年月光 阅读(107) 评论(0) 推荐(0) 编辑

memset

摘要: #include <cstring> #include <iostream> using namespace std; int main() { int a[2][2]; int n=2,m=2; for(int i=0;i<n;i++) for(int j=0;j<m;j++) { cin>>a[ 阅读全文
posted @ 2017-05-28 23:52 那年月光 阅读(97) 评论(0) 推荐(0) 编辑

(QT)在命令行编译ui文件和程序

摘要: 1.新建helloworld_2文件夹,将helloworld里的main.cpp和hellodialog.cpp两个文件复制过来。 2.打开控制台。此时不能用cmd,否则不能出最后的结果(lz在运行到mingw32-make这一步的时候就出现问题了),要在开始-QT里找到QT5.5 for des 阅读全文
posted @ 2017-05-28 18:36 那年月光 阅读(813) 评论(0) 推荐(0) 编辑

'mingw32-make' 不是内部或外部命令,也不是可运行的程序 或批处理文件。(的解决方案)

摘要: 问题如上。 解决方案:找到mingw32-make,方法是在计算中搜索 然后将其复制到C:Windows\System32下,需要管理员权限才能复制的情况下直接点继续。然后就可以了。 阅读全文
posted @ 2017-05-28 18:13 那年月光 阅读(16947) 评论(0) 推荐(1) 编辑

动态一维、二维输入数组变量

摘要: 动态输入一维变量: #include <iostream>using namespace std;int main(){int n; cin>>n; int *p=new int[n]; for(int i=0;i<n;i++) { cin>>p[i]; }for(int i=0;i<n;i++) 阅读全文
posted @ 2017-05-27 23:31 那年月光 阅读(155) 评论(0) 推荐(0) 编辑

精度

摘要: 1.#include<iomanip> cout<<setiosflags(ios::fixed)<<setpricision(4)<<4<<endl; 输出为4。 如果 float a=4; cout<<setiosflags(ios::fixed)<<setpricision(4)<<4<<en 阅读全文
posted @ 2017-05-27 23:04 那年月光 阅读(148) 评论(0) 推荐(0) 编辑

冒泡排序法

摘要: #include using namespace std; //上下为验证,此处为核心。 void bubbleSort(int a[], int N) { for(int i = 0; i a[j+1]) { int temp = a[j]; a[j] = a[j+1]; ... 阅读全文
posted @ 2017-05-26 21:46 那年月光 阅读(107) 评论(0) 推荐(0) 编辑

g++

摘要: 1.Ctrl+Alt+T调出控制台。 2.编译运行代码过程: a.写一个test.cpp文件,在里面写代码,写完保存。 b.控制台:g++ test.cpp -o test 回车 c.控制台:./test即可。 阅读全文
posted @ 2017-05-24 21:13 那年月光 阅读(116) 评论(0) 推荐(0) 编辑