
C语言
文章平均质量分 63
Dynamic5210
这个作者很懒,什么都没留下…
展开
-
文件复制
#include #include int main(){ FILE *in,*out; char ch,name1[10],name2[10]; printf("请输入要用的文件的名称:"); scanf("%s",name1); printf("请输入要输入数据的文件:"); scanf("%s",name2); if((in=fopen(name1,"r"))==NULL)原创 2016-12-20 14:42:42 · 311 阅读 · 0 评论 -
计算机图书
10月书讯中奖名单:_iorilan、极简、逆流的鱼yuiop、mlcjq、Marksinoberg。好书推荐,在图灵书讯中选出你认为值得推荐的好书加推荐理由或推荐语,在文末评论里回复。下期书讯更新时,会在本期的书讯评论中选出若干优秀评论,获奖者可任选图灵书讯中的图书一本。11月有13本新书上市,有重磅推荐3本,还有体验设计和平面设计3本,有纯技术类4本,还有数学和科普3本,涉猎甚广。转载 2016-11-25 09:37:38 · 541 阅读 · 0 评论 -
完全背包(改进一维数组)
完全背包GoodscapacityweightA23B12C34D22问题:有n种物品,每种物品有无限个,每个物品的重量为weight[i],每个物品的价值为v原创 2016-11-18 20:12:19 · 297 阅读 · 0 评论 -
01背包(dp)
0,1背包问题GoodscapacityweightA23B12C34D22 题目:有N件物品和一个容量为V的背包。第i件物品的重量是weight[i],价原创 2016-11-18 12:19:35 · 292 阅读 · 0 评论 -
线性表1(顺序存储)
#include #include #include #include #define OK 1#define ERROR 0#define TRUE 1#define FALSE 0#define MAXSIZE 20//存储初始分配量 typedef int Status;//Status是函数的类型 typedef int ElemType;Status v原创 2016-11-21 20:14:37 · 364 阅读 · 0 评论 -
include <io.h>
io.h头文件下的一些函数标签: pathaccesscbuffer磁盘system2010-07-16 16:01 9201人阅读 评论(0) 收藏 举报write()写文件函数原形:int write(int handle,char *buf,unsigned len)用法:write(文件句柄,缓冲区地址,缓冲区字节长度);功能:将缓冲区的数据写入与h转载 2016-11-21 14:55:53 · 7482 阅读 · 1 评论 -
算法时间复杂度
题目:已知数组a[n]中的元素为整型,设计算法将其调整为左右两部分,左边所有的元素为奇数,右边所有元素为偶数,并要求算法的时间复杂度为O(n^2)。#include int main(){ int i,j,a[100],k,m,l,n,z,w,b; scanf("%d",&m); for(i=0;i<m;i++){ scanf("%d",&a[i]); } z=m/2; n=原创 2016-11-19 15:16:51 · 481 阅读 · 0 评论 -
多重背包
多重背包 WeightValueAmountA233B122C341D222问题:有n种物品,每种物原创 2016-11-18 23:01:40 · 238 阅读 · 0 评论 -
完全背包
完全背包GoodscapacityweightA23B12C34D22问题:有n种物品,每种物品有无限个,每个物品的重量为weight[i],每个物品的价值为v原创 2016-11-18 18:49:02 · 379 阅读 · 0 评论 -
atdilb.h
stdlib.h 编辑本词条缺少名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧!stdlib 头文件即standard library标准库头文件。stdlib.h里面定义了五种类型、一些宏和通用工具函数。 类型例如size_t、wchar_t、div_t、ldiv_t和lldiv_t; 宏例如EXIT_FAILURE、EXIT_SUCCESS、RAND_转载 2016-10-20 09:33:02 · 721 阅读 · 0 评论 -
利用结构体来写冒泡排序问题
#include#include#define MAX_SIZE 10typedef struct{ int r[MAX_SIZE + 1]; int length;} SqList;void swap( SqList* L, int i, int j ){ int temp = L->r[i]; L->r[i] = L->r[j]; L->r[j] = temp;原创 2016-10-20 09:26:21 · 1262 阅读 · 0 评论 -
结构体1
//输入两个学生的学号,姓名和成绩//输出成绩最好的学生的学号成绩和姓名 #include struct student{int sd;char name[10];int sc; };int main(){student student1,student2;scanf("%s %d %d",&student1.name,&student1.sc,&stude原创 2016-12-16 21:47:47 · 235 阅读 · 0 评论 -
细节成就未来(输出格式)
#include int main(){float a=1.23;printf("%6.2f",a); return 0;}原创 2016-12-16 21:55:30 · 225 阅读 · 0 评论 -
file
#include #include int main(){ FILE *fp; char ch,filename[10]; printf("请输入所用文件名:"); scanf("%s",filename); if((fp=fopen(filename,"w"))==NULL){ printf("无法打开此文件\n"); exit(0); } ch=getchar()原创 2016-12-20 14:05:00 · 369 阅读 · 0 评论 -
后缀
后缀:用来表示文件的性质,一般不超过3个字母。如:doc(word生成的文件),txt(文本文件),dat(数据文件),c(c语言文件),cpp(c++源程序文件),for(FORTRAN语言源程序文件),pas(Pascal语言源程序文件),obj(目标文件),exe(可执行文件),ppt(电子幻灯文件),bmp(图形文件).原创 2016-12-20 13:00:52 · 257 阅读 · 0 评论 -
细节决定未来(公用体类型)
//有若干个人员的数据,其中有学生和教师//学生的数据中包括:姓名,号码,性别,职业,班级//教师的数据包括:姓名,号码,性别,职位,职务//要求用同一个表格来处理 #include struct{ int num; char name[10]; char sex; char job; union { int clas; char position[10]; }c原创 2016-12-18 16:10:17 · 263 阅读 · 0 评论 -
细节决定未来(输出链表)
//输出链表 #include #include #define LEN sizeof(struct student)struct student{ long num; float score; struct student *next; }; int n;struct student*creat(void){ struct student *head,*p1,*p2; n原创 2016-12-18 13:30:10 · 261 阅读 · 0 评论 -
细节决定未来(建立动态链表)
//建立动态链表 #include #include #define ELN sizeof(struct student)struct student{ long num; float score; struct student *next; };int n;struct student*creat(void){ struct student*head,*p1,*p2; n原创 2016-12-18 09:40:51 · 250 阅读 · 0 评论 -
细节决定未来(静态链表建立)
//建立简单单链表 #include struct student{ int num; float score; struct student *next; }; int main(){ struct student a,b,c,*head,*p; a.num=10101;a.score=98.5; b.num=10103;b.score=78; c.num=10106;c.原创 2016-12-17 21:29:01 · 249 阅读 · 0 评论 -
细节决定成败(用结构体变量和结构体指针变量的指针做函数参数)
//有n个结构体变量,//内含学生学号,//姓名和3门//课程成绩//要求输出平均成绩最高//的学生的信息//包括学号,姓名,//3门课程成绩和平均成绩 #include #define n 3struct student{ int num; char name[20]; float score[3]; float aver; };int main(){ void原创 2016-12-17 16:55:15 · 886 阅读 · 0 评论 -
细节决定成败(指向结构体指针)
//指向结构体变量的指针 #include #include struct student{ long num; char name[20]; char sex; float score; };int main(){ struct student stu_1; struct student *p; p=&stu_1; p->num=10101; strcpy(stu_1原创 2016-12-17 13:40:41 · 292 阅读 · 0 评论 -
细节成就未来(结构体数组替换)
测试数据:12 he 3413 hu 3514 ni 118 bu 9811 ko 9019 by 734 vy 3333 bg 4455 bj 322 v 431 jh 24 bsw 5476 hgh 96578 bsvd 76222 scdsc 4546 df 6323 add 6524 dsvf 8225 xacd原创 2016-12-17 09:08:41 · 790 阅读 · 0 评论 -
细节成就未来(结构化数组)
//有三个候选人,每个选民只能投票选一人//要求编一个统计选票的程序,先后输入//被选人的名字, 最后输出各人的得票结果 #include #include struct person{ char name[10]; int count; }leader[3]={"li",0,"ke",0,"hai",0};//定义结构体数组 int main(){ char lead_nam原创 2016-12-16 22:25:55 · 306 阅读 · 0 评论 -
面向对象3
前边八篇博客写了从面向过程的方法来开发一款软件的各种方法,和过程。包括了计划,需求分析,设计,程序功能的实现,测试,维护还有界面设计的多项。但是,随着技术的发展,随着IT业的发展,面向对象的技术,已经发展的越来越广泛。这篇博客,我就给大家概要介绍一下面向技术相关技术! 首先看一下要总结知识的几大项: 初次我们从面向过程走向面向对转载 2016-10-20 09:48:32 · 192 阅读 · 0 评论 -
面向对象2
一般的,单纯从面向对象编程这方面来说,我们需要先理解对象的概念,以及为什么我们要使用面向对象编程,以及跟传统过程化编程之间的优劣。对象(object),即将一组数据与这组数据有关操作组装在一起,形成一个实体,这个实体就是对象。用通俗的话来讲,一个人也可以算是一个对象,这个对象可能包含一些属性(attribute),例如男性女性,这个对象也会有一些功能,例如让转载 2016-10-20 09:46:41 · 250 阅读 · 0 评论 -
冒泡排序
c语言代码#include //输入n个数,最后按从大到小的顺序输出 cint main(){ int shu[100],n,m,i,c,t; scanf("%d",&c); for(i=0;i<c;i++){ scanf("%d",&shu[i]); } for(n=0;n<c;n++){ for(m=0;m<c-n;m++){ if(shu[m+1]>shu[m])原创 2016-09-21 22:48:04 · 288 阅读 · 0 评论 -
剪刀石头布
题目描述石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头。如果两个人出拳一样,则不分胜负。在《生活大爆炸》第二季第 8 集中出现了一种石头剪刀布的升级版游戏。升级版游戏在传统的石头剪刀布游戏的基础上,增加了两个新手势:斯波克:《星际迷航》主角之一。蜥蜴人:《星际迷航》中的反面角色。这五种手势的胜负关系如表一所示,表中列出的是甲对乙的游戏结果。现在,小原创 2016-09-20 18:32:43 · 740 阅读 · 0 评论 -
rightmost digit
竞技场测试中 可以使用acmclub各校账号登录问题 B: Rightmost Digit时间限制: 1 Sec内存限制: 32 MB提交: 105解决: 23提交状态题目描述Given a positive integer N, you should outpu原创 2016-09-23 09:11:22 · 275 阅读 · 0 评论 -
电梯
题目描述The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It cos原创 2016-09-22 22:22:36 · 1294 阅读 · 0 评论 -
moving tables贪心算法
题目描述The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 200 rooms each on the north side and south side along原创 2016-10-09 08:21:58 · 763 阅读 · 0 评论 -
遇到输出超现时的解决方案
#include #include int main(){ double a,A; int i,m=0,n=0,l; scanf("%lf",&a); scanf("%d",&l); for(i=1,A=a;i<l;i++){ int s=i*a+0.5; if(s<=l){ double t=fabs(a-s*1./i); if(A>t){ A=t;转载 2016-09-06 22:29:55 · 336 阅读 · 0 评论 -
蛇形
Give you many positive integer N (N<=23), for each N, just output N*(N+1)/2 integers in a single line, separated by space. (Don't ask me why.) For each N, the output line contains integers from 1 to原创 2016-09-15 18:55:00 · 621 阅读 · 1 评论 -
最省油费
题目描述小明为了节省花费,决定驾驶最老式的燃油汽车以最少的费用从一个城市到另一个城市(假设出发时油箱是空的)。给定两个城市之间的距离D1、汽车油箱的容量C(以升为单位)、每升汽油能行驶的距离D2、出发点每升汽油价格P和沿途油站数N(N可以为零),油站i离出发点的距离Di、每升汽油价格Pi(i=1,2,…,N)。计算结果四舍五入至小数点后两位。如果无法到达目的地,则输出“No Solutio原创 2016-09-15 18:53:24 · 384 阅读 · 0 评论 -
火星人
题目描述人类终于登上了火星的土地并且见到了神秘的火星人。人类和火星人都无法理解对方的语言,但是我们的科学家发明了一种用数字交流的方法。这种交流方法是这样的,首先,火星人把一个非常大的数字告诉人类科学家,科学家破解这个数字的含义后,再把一个很小的数字加到这个大数上面,把结果告诉火星人,作为人类的回答。火星人用一种非常简单的方式来表示数字——掰手指。火星人只有一只手,但这只手上有成千上万的手指原创 2016-09-15 18:50:27 · 1391 阅读 · 0 评论 -
排列习题
#include void quicksort(int *a,int left,int right){ int temp,j,i,t; if(left > right) return; temp=a[left]; i = left; j = right; while(i != j){ while(a[j] >= temp && i < j) j--; w原创 2016-09-22 09:27:58 · 297 阅读 · 0 评论 -
递推
题目描述我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。输入输入数据的第一行是一个整数n(0输出对于每个测试实例,请输出平面的最大分割数,每个实例的输出占一行。样例输入12样例输出27#原创 2016-10-13 21:51:55 · 240 阅读 · 0 评论 -
面向对象
面向对象三大基本特性,五大基本原则透切理解面向对象三大基本特性是理解面向对象五大基本原则的基础.三大特性是:封装,继承,多态 所谓封装,也就是把客观事物封装成抽象的类,并且类可以把自己的数据和方法只让可信的类或者对象操作,对不可信的进行信息隐藏。封装是面向对象的特征之一,是对象和类概念的主要特性。 简单的说,一个类就是一个封装了数据以及操作这些数据的代码的逻辑实体。在一个对象内部,某原创 2016-10-20 09:42:23 · 228 阅读 · 0 评论 -
快速排序
c语言//快速排序 从小到大 #include int a[101];void quicksort(int left, int right){//left和right是一组数组里面最左边和最右边的下标 int temp,t,i,j; if(left > right) return ; temp = a[left];//temp是基准值就是拿来比较的数 i原创 2016-09-22 07:45:02 · 242 阅读 · 0 评论 -
merging sort(迭代取代递归)
#include void merge(int sr[],int tr[],int i,int m,int t){ int j,k,l; for(k=i,j=m+1;i<=m && j<=t;k++){ if(sr[i]<sr[j]){ tr[k]=sr[i++]; } else{ tr[k]=sr[j++]; } } if(i<=m){ for(l=0;原创 2016-10-29 09:25:31 · 301 阅读 · 0 评论 -
shellsort
#include #include #define maxsize 10typedef struct{ int a[maxsize+1]; int length;}sqlist;void shellsort(sqlist*l){ int i,j; int increment=l->length; do{ increment=increment/3+1; for(i=原创 2016-10-23 22:36:38 · 359 阅读 · 0 评论