C语言基础
最爱吃豆腐
奋斗啊,努力啊
展开
-
C语言笔记---(1)
安全问题?strcpy和strcat中都可能出现安全问题;因为返回的目的地(数组)可能没有足够的空间;解决方案安全的版本:char * strncpy(char *restrict dst,const char *restrict src,size_t n);char *strncat(char *restrict s1,const char *restrict s2,size_t n);原创 2016-11-26 12:52:15 · 229 阅读 · 0 评论 -
PAT乙级真题
#include <stdio.h>#include <string.h>#define N 1000//定义一个指针数组,数组中的每一个元素都是指针 const char *c[10] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};void read(int sum); //读出函数声原创 2017-01-25 10:12:01 · 944 阅读 · 4 评论 -
快速排序优化版
#include <stdio.h>#include <stdlib.h>void InsertSort(int arr[],int len);void quickSort(int arr[],int len);void quickSort_imp(int arr[],int start,int end);int patition(int arr[],int start,int end);void转载 2017-10-19 11:54:19 · 203 阅读 · 0 评论 -
浙大数据结构-HuffMan Code
树9 Huffman CodesIn 1953, David A. Huffman published his paper “A Method for the Construction of Minimum-Redundancy Codes”, and hence printed his name in the history of computer science. As a professor原创 2017-10-19 12:42:07 · 23582 阅读 · 0 评论 -
邻接矩阵和邻接图
/* 图的邻接矩阵表示法 */#define MaxVertexNum 100 /* 最大顶点数设为100 */#define INFINITY 65535 /* ∞设为双字节无符号整数的最大值65535*/typedef int Vertex; /* 用顶点下标表示顶点,为整型 */typedef int WeightType; /* 边的权原创 2017-10-27 20:08:24 · 4089 阅读 · 1 评论 -
浙大题--旅游规划
旅游规划(25 分)有了一张自驾旅游路线图,你会知道城市间的高速公路长度、以及该公路要收取的过路费。现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径。如果有若干条路径都是最短的,那么需要输出最便宜的一条路径。输入格式:输入说明:输入数据的第1行给出4个正整数N、M、S、D,其中N(2≤N≤500)是城市的个数,顺便假设城市的编号为0~(N−1);M是高速公路的条数;S是出发原创 2017-11-07 17:57:49 · 3959 阅读 · 0 评论