C语言
文章平均质量分 65
fengzhongzhui_feng
这个作者很懒,什么都没留下…
展开
-
出随机数利用rand函数与延迟时间函数
#include#include#includevoid main(){ while(true) { Sleep(500); /*暂停5s Sleep S大写 */ int num=rand()%47+1; printf("%4d",num); }} 注:此处的出的是1-47之间的随机数。原创 2016-09-05 21:35:07 · 1602 阅读 · 0 评论 -
C语言实现遗传算法
算法框架:1. GenerateInitialPopulation();//生成初代种群2. EvaluatePopulation();//评估种群3. GenerateNextPopulation();//产生下一代 1).SelectionOperator();//选择 2).CrossoverOperator();//交叉 RandomDi...原创 2018-03-12 17:49:52 · 3414 阅读 · 0 评论 -
银行家算法
运行环境VS 2010// banker.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#includetypedef struct Max1 // 资源的最大需求量{ int m_a;int m_b;int m_c;}Max; typedef struct Alloc原创 2017-10-15 20:56:21 · 1289 阅读 · 0 评论 -
进程调度模拟
运行环境 VS 2010// 进程调度.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include const int block_time=10; //定义时间片的长度为10秒 const int MAXPCB=100; //定义最大进程数typedef struct node //定义进原创 2017-10-15 20:53:55 · 1458 阅读 · 0 评论 -
稀疏矩阵运算器
// 稀疏矩阵计算器.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#define MAXSIZE 12500#define OK 1typedef int ElemType;typedef int Status;typedef struct{int i,j;ElemType e;}Triple;typedef原创 2017-07-19 20:30:33 · 863 阅读 · 0 评论 -
集合的交 并 补运算
#include "stdafx.h"#define set_max_length 100typedef struct {int a[set_max_length];int length;}set;void Input(set &A){printf("Please enter the set length=");scanf("%d",&A.length);for原创 2017-07-21 10:15:07 · 3439 阅读 · 0 评论 -
C语言用链表实现插入排序
#include "stdafx.h"#includestruct student{ int score; struct student *next;};struct student *head=(struct student *)malloc(sizeof(struct student));struct student *head1=(struct student *原创 2016-11-13 16:43:29 · 1131 阅读 · 0 评论 -
C语言利用链表计算k^N 1<k<=9;
#include "stdafx.h"#includestruct number{ int num; struct number *next;};int _tmain(int argc, _TCHAR* argv[]){ int N,jinwei=0,value,a[100],sign=0,k; struct number *head,*temp,*p; h原创 2016-11-08 22:36:33 · 331 阅读 · 0 评论 -
C语言从文本文件中用字符串读取一行数据,然后再依次遍历字符串将字符串中数据分配。
#include "stdafx.h"#include#includeFILE *rfile=fopen("D:\\风中追风\\工作量表计算.csv","r");// 定义文件指针;int _tmain(int argc, _TCHAR* argv[]){ int i=0,number; double num; char p[5000],nam原创 2016-11-08 22:26:25 · 8027 阅读 · 0 评论 -
学生成绩计算修订
#include "stdafx.h"#include #include struct student{ int num; int score;};int sign[47];struct student stus[47];int stucount=47;double sum( ){ double s=0; for(int i=0;i {原创 2016-10-24 15:34:27 · 272 阅读 · 0 评论 -
利用结构体计算班级平均分,最高分,最低分,不及格等等
#include "stdafx.h"#include #include struct student{ int num; int score;};struct student stus[47]; //根据班级人数可修改,此处默认47人。int stucount=47;double sum( ){ double s=0; for(int i=0;i原创 2016-10-21 11:45:16 · 4202 阅读 · 0 评论 -
小球随机出现在屏幕
#include#include#includevoid main(){ int i,posX,posY; while(true) { system("cls"); Sleep(50); posX=rand()%120+1; /*屏幕的行数*/ posY=rand()%30+1; /*屏幕的列数*/ for(i=0;i原创 2016-09-05 21:43:25 · 529 阅读 · 0 评论 -
C语言 产生随机数
需添加头文件stdlib.h。随机函数 int rand(void)。随机数范围0<rand()<RAND_MAX(RAND_MAX根据不同的计算机系统值不同)。使用rand()前,需先使用随机种子数函数 srand()设置随机数种子,若未设置,默认为1。生成某个范围内的随机数1.生成[0,N]之间的某个整数: rand()%(N+1);2.生成[N,M]之间的某个整数(M>...原创 2018-03-13 08:27:47 · 478 阅读 · 1 评论