大一水题
Aaron_Kitty
这个作者很懒,什么都没留下…
展开
-
2月1日
#include using namespace std;int main (){ int n,j,i; cin >> n; for(i=1;i for(j=1;j cout } cout for(j=1;j cout原创 2018-02-01 20:16:18 · 119 阅读 · 0 评论 -
TeX中的引号
/*之前学习了使用“scanf("%s")”输入字符串但却不能在本题中使用它,因为它碰到空格 或者TAB就会停下来*/#include<cstdio>int main(){ int c, q = 1;/*第一种方法是使用“fgetc(fin)”, 它读取一个打开的文件fin,读取一个字符,然后返回一 个int值。 为什么返回的是int而不是char呢?因为如果文件结束...原创 2018-03-04 15:47:15 · 166 阅读 · 0 评论 -
快速排序(能力还是不够)
#include <stdio.h>//交换两个值void swap(int a[], int i, int j){ int t = a[i]; a[i] = a[j]; a[j] = t;}int partition(int a[], int p, int r){ int i = p; int j = r + 1; int x = a[p];//中间量 whi...原创 2018-03-31 16:54:45 · 174 阅读 · 0 评论 -
结构体()
#include <iostream>using namespace std;struct complex //定义全局变量结构体{ float real,image;//描述的是负数的实部和虚部};void swap1(complex &c1,complex &c2){ complex t = c1; c1 = c2; c2 = t;}//引用...原创 2018-05-17 10:35:45 · 506 阅读 · 0 评论 -
字符串处理
#include <iostream>#include <cstring>using namespace std;int main(){ char s1[] = "today",s2[] = "yesterday\0gone\0";//原型 Int strlen(const char *s) //求字符指针s所指字符串中第一个结束符‘\0’前的字符 // ...原创 2018-05-04 11:01:44 · 123 阅读 · 0 评论 -
求两个集合的并集
#include <iostream>using namespace std;int main(){ int m,n,i,j,k,l; int *a,*b,*c; cin >> m; cin >> n; l = m; a = new int [m]; b = new int [n]; c = new int [m+...原创 2018-04-27 12:45:18 · 4945 阅读 · 1 评论 -
选择排序
#include <iostream>using namespace std;void selectsort(int [],int);int main(){ int a[10],i; cout << "Please input 10 integers:" << endl; for(i=0; i<10; i++) cin &g...原创 2018-05-27 12:21:17 · 145 阅读 · 0 评论 -
排序合集
插入排序插入排序的基本思想每一步将一个待排序元素按其关键字值的大小插入到已排序序列的适当位置上,直到待排序元素插入完为止。插入排序的示意图例9-11 直接插入排序函数模板template <class T>void insertionSort(T a[], int n) { int i, j; T temp; for (int i = 1; i < n...原创 2018-05-27 12:51:49 · 1446 阅读 · 0 评论 -
python导入txt文档矩阵乘法
#矩阵乘法ls = []#存入第二个列表result = []#存入第一个矩阵a = []#存入的是第二个矩阵的行和列b = []#存入的是第一个#矩阵的行和列fd = open("D:\新建文本文档.txt", "r")#打开第一个文档#fo = open("D:\hc.txt", "r")for line in fd.readlines(): result.append(l...原创 2018-05-28 19:35:20 · 1419 阅读 · 0 评论 -
管理系统c++
#include<cstdio>#include <cstdio>#include <windows.h> //一些基本的库函数的头文件#include <cstring>#include <iostream> //字符处理头文件#define N 100using namespace std;struct employee //雇员...原创 2018-06-12 01:23:19 · 385 阅读 · 0 评论 -
矩阵相乘c++实现
#include <iostream>using namespace std;#define MAXX 100int a[MAXX][MAXX];int b[MAXX][MAXX];int main(){ int m,n,l,k; cin >> m >> n >> l >> k; for(int i=0; i<m;...原创 2018-05-31 08:46:14 · 2466 阅读 · 2 评论 -
公有继承
#include <iostream>using namespace std;class point{ float x; protected: float y; public: float z; point(float x,float y,float z){ this -> x = x;this -> y =y;this ->...原创 2018-06-26 21:29:26 · 728 阅读 · 0 评论 -
电子宠物+原创
/*加入猜数字游戏和数洼地(深度搜索)和手机键盘游戏(codevs)和原创打怪,基础实训能力有限欢迎指导*/#include <iostream>#include <ctime>#include <cmath>#include <cstdlib>#include <cstring>using namespace std;...原创 2019-07-10 21:05:37 · 1046 阅读 · 0 评论 -
蛇形填数
#include<cstdio>#include<cstring>#define maxn 100int a[maxn][maxn];int main(){ int n, x, y, tot = 0; scanf("%d", &n); memset(a, 0, sizeof(a)); tot = a[x=0][y=n-1] = 1;//,则一...原创 2018-03-03 16:40:21 · 166 阅读 · 0 评论 -
C++格式化输出,C++输出格式控制
C++格式化输出,C++输出格式控制 在输出数据时,为简便起见,往往不指定输出的格式,由系统根据数据的类型采取默认的格式,但有时希望数据按指定的格式输出,如要求以十六进制或八进制形式输出一个 整数,对输出的小数只保留两位小数等。有两种方法可以达到此目的。一种是我们已经介绍过的使用控制符的方法(详情请查看:C++输入cout与输出cin);第2种是使用流对象的有关成员函数。分别叙述如下。使用控制符控...转载 2018-03-03 16:38:58 · 2291 阅读 · 0 评论 -
构造函数
构造函数构造函数的作用l 在对象被创建时使用特定的值构造对象,将对象初始化为一个特定的初始状态。l 例如:n 希望在构造一个Clock类对象时,将初试时间设为0:0:0,就可以通过构造函数来设置。构造函数的形式l 函数名与类名相同;l 不能定义返回值类型,也不能有return语句;l 可以有形式参数,也可以没有形式参数;l 可以是内联函数;l原创 2018-05-27 12:24:20 · 225 阅读 · 0 评论 -
iomanip
在c++程序里面经常见到下面的头文件#include 这里面iomanip的作用比较多:主要是对cin,cout之类的一些操纵运算子,比如setfill,setw,setbase,setprecision等等。它是I/O流控制头文件,就像C里面的格式化输出一样.以下是一些常见的控制函数的:dec 置基数为10 相当于"%d"hex 置基数为16 相当于"%X"oct 置转载 2018-02-03 23:35:43 · 555 阅读 · 0 评论 -
pair
air类型概述pair是一种模板类型,其中包含两个数据值,两个数据的类型可以不同,基本的定义如下: pair<int, string> a;表示a中有两个类型,第一个元素是int型的,第二个元素是string类型的,如果创建pair的时候没有对其进行初始化,则调用默认构造函数对其初始化。 pair<string, string> a("James", "Joy");也可以像...转载 2018-02-08 19:40:38 · 226 阅读 · 0 评论 -
宽度优先搜索迷宫问题
#include <iostream>#include <queue>#define MAX_N 100#define MAX_M 101using namespace std;const int INF = 100000000;//使用pair表示状态时,使用typedef会更加方便一点。typedef pair<int, int> P;//输入char ma...原创 2018-02-08 21:06:04 · 549 阅读 · 0 评论 -
cb使用教程
CodeBlocks简单的使用说明入门篇双击桌面上CodeBlocks图标,就能进入CodeBlocks集成环境,屏幕上就会出现CodeBlocks的主界面如下图在CodeBlocks主窗口的顶部是CodeBlocks的主菜单栏。其中包含15个菜单项:File(文件)、Edit(编辑)、View(查看)、Search(搜寻)、Project(项目)、Build(构建)、Debug(调试)、Fort...转载 2018-02-08 21:15:36 · 29805 阅读 · 9 评论 -
简易队列和栈
#include #include #include using namespace std;int main(){ stacks; s.push(1); s.push(2); s.push(3); printf("%d\n",s.top()); s.pop(); printf("%d\n",s.top()); s.p原创 2018-05-27 12:25:18 · 265 阅读 · 0 评论 -
深度优先搜索laking counting poj2386
#include #define MAX_N 110int N,M;char field[MAX_N][MAX_N];//创建园子using namespace std;void dfs(int x,int y){ field[x][y]='.';//把现在的位置改为. //循环遍历移动的八个方向 for(int dx=-1; dx原创 2018-02-06 21:09:17 · 151 阅读 · 0 评论 -
穷竭搜索
#include #define MAX_N 1000int a[MAX_N];int k;int n; //将其设为全局变量便于使用bool dfs(int i, int sum) //分别表示当前函数的序号和前i个中的若干数的和{ if(i == n ) return sum == k; ///if(sum == k) return true; //原创 2018-02-06 21:13:28 · 125 阅读 · 0 评论 -
常州大学寒假练习题解
A.添加逗号 题目描述 对于一个较大的整数 N(1<=N<=2,000,000,000) 比如 980364535,我们常常需要一位一位数这个数字是几位数,但是如果在这 个数字每 三位加一个逗号,它会变得更加易于朗读。 因此,这个数字加上逗号成如下的模样:980,364,535 请写一个程序帮她完成这件事情 输入描述: 一行一个整数 N 输出描述: 一行一个字符串表示添加完逗号的结...原创 2018-02-08 18:28:52 · 698 阅读 · 0 评论 -
简单min函数介绍
对于最简单的min函数,心得:一般来讲,它定义在std之中,using namespaces std即可。一般的c语言我没有发现合适的头文件,自己定义吧,蛮简单的定义宏 #define max(a,b) ( ((a)>(b)) ? (a):(b) )#define min(a,b) ( ((a)>(b)) ? (b):(a) )定义函数 int max(int a,int b){ret...原创 2018-02-18 11:54:44 · 12031 阅读 · 0 评论 -
贪心算法,简单的背包问题
有错纠错谢了。#include <iostream>using namespace std;//硬币的面值const int v[6]={1,5,10,50,100,500};//输入int c[6];int a;int main(){ int ans=0; cin >> a; for(int j=0;j<6;j++){ cin >...原创 2018-02-18 11:55:45 · 292 阅读 · 0 评论 -
二分法求方程的解
/*求下面方程的一个根:f(x)=x^3-5x^2+10x-80=0若求出一个根为a,则要求f(a)的绝对值小于10^-6解法,求导缩小为0,100,用二分的方法在[0,100]内求解*/#include <iostream>#include <cmath>#include <cstdio>using namespace std;double EPS = 1e-...原创 2018-03-01 19:33:46 · 1577 阅读 · 0 评论 -
开灯问题
/*开灯问题。有n盏灯,编号为1~n。第1个人把所有灯打开,第2个人按下所有编号为2 的倍数的开关(这些灯将被关掉),第3个人按下所有编号为3的倍数的开关(其中关掉的灯 将被打开,开着的灯将被关闭),依此类推。一共有k个人,问最后有哪些灯开着?输 入n和k,输出开着的灯的编号。k≤n≤1000。样例输入:7 3样例输出:1 5 6 7【分析】用a[1],a[2],…,a[n]表示编号为1,2,3,...原创 2018-03-01 20:29:43 · 485 阅读 · 0 评论 -
Android Studio入门第一天总结
小白入门当然是先从helloworld开始创建完直接报错按照他的路径提示我打开了bulid.gradle,查阅之后,了解到comileSdkVersion用于指定项目的编译版本,系统默认了28,在tools—Android——Sdkmanager——updates可以看到我的版本是26.1.1,于是将28改为26.编译成功.而后是在创建和加载布局出出现问题解决方案,他默认a...原创 2018-08-17 22:23:34 · 805 阅读 · 0 评论