C语言
tara_int
我的程序成长史。
展开
-
二维数组—S型排座问题
S型排座问题 1 6 7 122 5 8 113 4 9 10#includeint main(){ int n, m, s[100][100], z, i, j; while(scanf("%d%d", &n, &m) != EOF) { z = 1; for(j = 1; j原创 2017-12-22 15:23:31 · 1904 阅读 · 0 评论 -
基于邻接矩阵的广度优先搜索遍历(BFS) 深度优先搜索遍历(DFS)
//BFS#include <stdio.h>#include <stdlib.h>#include<string.h>int main(){ int t, n, m, start, i; int a[110][110], book[110], q[110]; scanf("%d", &t); while...原创 2018-08-14 14:35:52 · 618 阅读 · 0 评论 -
图结构练习——最短路径(Dijkstra 迪杰斯特拉算法) sdut 2143
#include <stdio.h>#include <stdlib.h>#define INF 0x3f3f3f3fint n, m, a[110][110];int vis[110], dist[110];void dijkstra(int v){ int i, j, k; for(i = 1; i <= n; i++) {...原创 2018-08-18 09:51:29 · 194 阅读 · 0 评论 -
Maximum Product UVA - 11059
注意:是序列,有顺序的,有顺序的,有顺序的。Given a sequence of integers S = {S1, S2, . . . , Sn}, you should determine what is the value of the maximum positive product involving consecutive terms of S. If you cannot ...原创 2018-08-17 17:30:52 · 113 阅读 · 0 评论 -
KMP算法
安利一下几个比较通俗易懂的KMP的算法解释: https://www.cnblogs.com/yjiyjige/p/3263858.html https://subetter.com/articles/2018/04/kmp-algorithm.html http://www.ruanyifeng.com/blog/2013/05/Knuth%E2%80%93Morris%...转载 2018-08-03 09:50:20 · 105 阅读 · 0 评论 -
堆排序 数据结构实验之排序四:寻找大富翁
#include<stdio.h>#define INF 0x3f3f3f3fint n, m, a[15];int size;int delete_max()//和插入思路很像,找到儿子比自己大的放在自己的位置,自己继续往下找,直到儿子都比自己小的时候,自己就坐定了{ int p, c, max, t; max = a[1]; //大顶堆,...翻译 2018-08-22 16:13:05 · 149 阅读 · 0 评论 -
HDU - 1032 ( 3n+1 n/2)
L - 10p HDU - 1032确实是水。 但是题目没有注明i 与 j 谁大谁小, 要先判断交换 Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this pro...翻译 2018-08-23 21:08:30 · 397 阅读 · 0 评论 -
HDU - 1272 (并查集 小希的迷宫)
G - 20p HDU - 1272 上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头...原创 2018-08-23 20:44:33 · 193 阅读 · 0 评论 -
最小生成树 oj 2144
n个点,有n-1条边就可连通, 总花费最小要选择 花费小 且 不会使各点连环 的 n-1条边快排对边长(费用)进行排序, merge函数中判断会不会成环, 边数达到n-1 break;#include <stdio.h>#include <stdlib.h>int m, n, f[110];struct node{ int u, v, w;}a[...原创 2018-08-23 21:16:25 · 539 阅读 · 0 评论 -
Message Flood oj 1500
Problem DescriptionWell, how do you feel about mobile phone? Your answer would probably be something like that "It's so convenient and benefits people a lot". However, If you ask Merlin this quest...原创 2018-08-24 09:41:44 · 96 阅读 · 0 评论 -
数据结构实验之查找七:线性之哈希表 oj 3379
哈希表的应用 Problem Description根据给定的一系列整数关键字和素数p,用除留余数法定义hash函数H(Key)=Key%p,将关键字映射到长度为p的哈希表中,用线性探测法解决冲突。重复关键字放在hash表中的同一位置。Input连续输入多组数据,每组输入数据第一行为两个正整数N(N <= 1500)和p(p >= N的最小素数),N是关键字总数,p是...原创 2018-08-24 09:44:45 · 441 阅读 · 0 评论 -
权势二进制 51Nod - 1413
E - 权势二进制 51Nod - 1413 找n中的最大的一位数,例如 398 = 3 * 111 + 5*11+1*10; 3+5+1 = 9127 = 1*111+ 1*11+5*1 ; 1+1+5 = 7;一个十进制整数被叫做权势二进制,当他的十进制表示的时候只由0或1组成。例如0,1,101,110011都是权势二进制而2,12,900不是。当给定一个n...原创 2018-08-24 20:06:55 · 110 阅读 · 0 评论 -
{A}+{B} HDU - 1412
E - {A}+{B}(10) HDU - 1412 Problem Description给你两个集合,要求{A} + {B}.注:同一个集合中不会有两个相同的元素.Input每组输入数据分为三行,第一行有两个数字n,m(0<n,m<=10000),分别表示集合A和集合B的元素个数.后两行分别表示集合A和集合B.每个元素为不超出int范围的整数,每个元素之间...原创 2018-08-24 20:19:58 · 184 阅读 · 0 评论 -
数据大搜索 UESTC - 59
数据大搜索 UESTC - 59 写一个程序,把一个字符串中的数字子序列找出来并转换成十进制整数输出。Input第一行是整数nn,表示测试的数据组数,下面是nn行无空格的字符串(长度不超过200)。题目保证字符串中含的整数位数小于99位,不考虑负数情形。Output每一行输入对应一行输出,一行中若有多个数据,每个数据后有一个空格。Sample Input100...原创 2018-08-25 09:39:41 · 138 阅读 · 0 评论 -
A or B Equals C
A or B Equals C Gym - 101028C Rami went back from school and he had an easy homework about bitwise operations (and,or,..) The homework was like this : You have an equation : " A | B = C " ( this ...原创 2018-08-29 20:58:10 · 280 阅读 · 0 评论 -
C语言调用qsort函数
数组排序, 后续补充其他情况 #include <stdio.h>#include <stdlib.h>int cmpfunc(const void *a, const void *b){ return ( *(int*)a - *(int*)b); //升序}/*int cmpfunc(const void *a, const voi...原创 2018-08-22 08:45:22 · 1115 阅读 · 0 评论 -
最大公约数与最小公倍数
https://baike.baidu.com/item/%E6%9C%80%E5%B0%8F%E5%85%AC%E5%80%8D%E6%95%B0/6192375最小公倍数https://baike.baidu.com/item/%E6%9C%80%E5%A4%A7%E5%85%AC%E7%BA%A6%E6%95%B0最大公约数 #include<stdio.h...原创 2018-08-16 11:06:29 · 279 阅读 · 0 评论 -
3n+1数列问题 sdut3535
3n+1数列问题Time Limit: 1000 ms Memory Limit: 65536 KiBSubmit StatisticProblem Description有一天小标遇到了经典的3n+1数链问题,他想知道3n+1数链的前k个数是多少。下面小标来给你介绍一下3n+1数链是什么,给定一个数n,如果n为偶数,那么下一个数n1 = n / 2;否则n1 = 3 * n...原创 2018-08-01 09:22:41 · 215 阅读 · 0 评论 -
数据结构实验之图论二:基于邻接表的广度优先搜索遍历 sdut 2142
#include <stdio.h>#include <stdlib.h>#include<string.h>struct node{ int data; struct node *next;};struct node *head[101], *p, *q;int book[101], n, m, start;void sort...原创 2018-08-15 10:18:42 · 643 阅读 · 0 评论 -
求n!(进位)
#include <stdio.h> int main() { int n; int a[9000]; //确保保存最终运算结果的数组足够大 int digit = 1; //位数 int temp; //阶乘的任一元素与临时结果的某位的乘积结果 int i, j, carry; //...原创 2018-09-09 14:49:43 · 150 阅读 · 0 评论