摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 4 /*全局变量*/ 5 int mSIZE; /*物理块数*/ 6 int pSIZE; /*页面号引用串个数*/ 7 static int memery[10]={0}; /*物理块中的页号*/ 8 sta
阅读全文
随笔分类 - 算法
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 4 /*全局变量*/ 5 int mSIZE; /*物理块数*/ 6 int pSIZE; /*页面号引用串个数*/ 7 static int memery[10]={0}; /*物理块中的页号*/ 8 sta
阅读全文
摘要:提交代码: 1 #include <stdio.h> 2 3 int main(){ 4 int row,col; //定义行数和列数 5 char c; 6 scanf("%d %c",&col,&c);//输入列数 欲使用的字符 7 //计算行数 8 if(col%2==1) row=col/2
阅读全文
摘要:提交代码: 注: 多组输入 scanf的返回值是输入值的个数。没有输入值就返回-1。 -1按位取反结果是0 while(~scanf("%d", &n))就是当没有输入的时候退出循环 1 #include <stdio.h> 2 3 4 #define maxn 210 5 6 int a[maxn
阅读全文
摘要:提交代码: 1 #include <stdio.h> 2 3 //定义常量 宏定义(宏替换) 4 #define maxn 100010 5 6 int school[maxn]={0}; 7 8 int main(){ 9 10 int n,schID,score; 11 scanf("%d",&
阅读全文
摘要:卡拉兹(Callatz)猜想 对任何一个自然数n,如果它是偶数,那么将他砍掉一半;如果它是奇数,那么把(3*n+1)砍掉一半。这样一直反复砍下去,最后一顶在某一步得到n=1。 卡拉兹在1950年的世界数学家大会上公布了这个猜想。 此处非要证明卡拉兹猜想,而是对给定的任何一个不超过1000的正整数n简
阅读全文
摘要:交换两个数的基本逻辑 1 #include <stdio.h> 2 3 int main(){ 4 int a[10]={3,1,4,5,2}; 5 int i,j,k; 6 for(i=1;i<=4;i++) {//进行n-1次比较 7 //从i趟时从a[0]到a[n-i-1]都与他们下一个数比较
阅读全文
摘要:算法 算法(Algorithm)是指解题方案的准确而完整的描述,是一系列解决问题的清晰指令,算法代表着用系统的方法描述解决问题的策略机制。也就是说,能够对一定规范的输入,在有限时间内获得所要求的输出。如果一个算法有缺陷,或不适合于某个问题,执行这个算法将不会解决这个问题。不同的算法可能用不同的时间、
阅读全文
|