Catherine_zhilin

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  C

摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 4 /*全局变量*/ 5 int mSIZE; /*物理块数*/ 6 int pSIZE; /*页面号引用串个数*/ 7 static int memery[10]={0}; /*物理块中的页号*/ 8 sta 阅读全文
posted @ 2019-09-06 11:34 kkkshiki 阅读(2450) 评论(0) 推荐(0)

摘要: 阅读全文
posted @ 2019-07-06 16:33 kkkshiki 阅读(147) 评论(0) 推荐(0)

摘要:提交代码: 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 阅读全文
posted @ 2019-07-06 14:45 kkkshiki 阅读(465) 评论(0) 推荐(0)

摘要:提交代码: 注: 多组输入 scanf的返回值是输入值的个数。没有输入值就返回-1。 -1按位取反结果是0 while(~scanf("%d", &n))就是当没有输入的时候退出循环 1 #include <stdio.h> 2 3 4 #define maxn 210 5 6 int a[maxn 阅读全文
posted @ 2019-07-06 14:43 kkkshiki 阅读(284) 评论(0) 推荐(0)

摘要:提交代码: 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",& 阅读全文
posted @ 2019-07-05 14:47 kkkshiki 阅读(182) 评论(0) 推荐(0)

摘要:卡拉兹(Callatz)猜想 对任何一个自然数n,如果它是偶数,那么将他砍掉一半;如果它是奇数,那么把(3*n+1)砍掉一半。这样一直反复砍下去,最后一顶在某一步得到n=1。 卡拉兹在1950年的世界数学家大会上公布了这个猜想。 此处非要证明卡拉兹猜想,而是对给定的任何一个不超过1000的正整数n简 阅读全文
posted @ 2019-07-05 14:44 kkkshiki 阅读(203) 评论(0) 推荐(0)

摘要:黑盒测试 系统会判断每组数据的输出结果是否正确。 单点测试只需要按正常的逻辑执行一遍程序即可。 多点测试: while...EOF型 while...(T--)型 在多点测试中,每次循环都要重置一下变量和数组,否则在下一次数据来临时变量和数组就不是初始状态了。 重置数组一般使用memset函数或者f 阅读全文
posted @ 2019-07-05 14:34 kkkshiki 阅读(230) 评论(0) 推荐(0)

摘要:时间按复杂度 空间复杂度 编码复杂度 阅读全文
posted @ 2019-07-05 14:18 kkkshiki 阅读(191) 评论(0) 推荐(0)

摘要:若想要手动提供id和gender初始化参数 或者: 这样可以直接在需要时对结构体变量赋值: 只要参数个数和类型不完全相同可以定义多个构造函数 应用实例:结构体Point 用于存放平面点的坐标x,y 1 #include <stdio.h> 2 3 struct Point{ 4 int x,y; 5 阅读全文
posted @ 2019-07-05 14:16 kkkshiki 阅读(494) 评论(0) 推荐(0)

摘要:对引用变量的操作就是对原变量的操作 1 #include <stdio.h> 2 3 void change(int&x){ 4 x=1; 5 } 6 int main(){ 7 int x=10; 8 change(x); 9 printf("%d\n",x); 10 return 0; 11 } 阅读全文
posted @ 2019-07-05 13:44 kkkshiki 阅读(132) 评论(0) 推荐(0)

摘要:1 #include <stdio.h> 2 3 void change (int *p){ 4 *p=233; 5 } 6 7 /*将变量的地址传入函数。在函数中对地址的元素进行改变,原先的数据也会改变*/ 8 int main(){ 9 int a=1; 10 int *p=&a; 11 cha 阅读全文
posted @ 2019-07-05 13:38 kkkshiki 阅读(198) 评论(0) 推荐(0)

摘要:1 #include <stdio.h> 2 3 /*数组名称也作为数组的首地址使用*/ 4 int main(){ 5 int a[10]={1}; 6 int *p=a; 7 printf("%d\n",*p); 8 return 0; 9 } 1 #include <stdio.h> 2 3 阅读全文
posted @ 2019-07-05 09:10 kkkshiki 阅读(192) 评论(0) 推荐(0)

摘要:1 #include <stdio.h> 2 3 /*在变量前面加上&就可以表示变量的地址*/ 4 int main(){ 5 int a=1; 6 printf("%d,%d\n",&a,a); 7 return 0; 8 } 指针变量 int* p; double* p; char* p; in 阅读全文
posted @ 2019-07-05 09:09 kkkshiki 阅读(149) 评论(0) 推荐(0)

摘要:1 #include <stdio.h> 2 3 int max_2(int a,int b){ 4 if(a>b) return a; 5 else return b; 6 } 7 8 /*在max_3中调用max_2比较大小*/ 9 int max_3(int a,int b,int c){ 1 阅读全文
posted @ 2019-07-05 08:42 kkkshiki 阅读(268) 评论(0) 推荐(0)

摘要:strlen()可以得到字符数组中第一个\0前的字符的个数 1 #include <stdio.h> 2 #include <string.h> 3 4 int main(){ 5 char str [10]; 6 gets(str); 7 int len=strlen(str); 8 printf 阅读全文
posted @ 2019-07-05 00:05 kkkshiki 阅读(280) 评论(0) 推荐(0)

摘要:1 #include <stdio.h> 2 3 int main(){ 4 char str[15]={'G','o','o','d',' ','s','t','o','r','y','!'}; 5 int i; 6 for(i=0;i<11;i++){ 7 printf("%c",str[i]) 阅读全文
posted @ 2019-07-04 22:01 kkkshiki 阅读(135) 评论(0) 推荐(0)

摘要:int a[5][6]; doube db[10][10]; char [256][256]; bool vis[1000][1000]; 1 #include <stdio.h> 2 3 int main(){ 4 int a[5][6]={{3,1,2},{8,4},{},{1,2,3,4,5} 阅读全文
posted @ 2019-07-04 15:18 kkkshiki 阅读(378) 评论(0) 推荐(0)

摘要:交换两个数的基本逻辑 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]都与他们下一个数比较 阅读全文
posted @ 2019-07-04 15:16 kkkshiki 阅读(356) 评论(0) 推荐(0)

摘要:数组 1 #include <stdio.h> 2 3 int main(){ 4 int a[10]={5,3,2,6,8,4}; 5 int i; 6 for(i=0;i<10;i++){ 7 printf("a[%d]=%d\n",i,a[i]); 8 9 } 10 return 0; 11 阅读全文
posted @ 2019-07-04 14:59 kkkshiki 阅读(142) 评论(0) 推荐(0)

摘要:常用math函数 1 #include <stdio.h> 2 #include <math.h> 3 4 /*绝对值*/ 5 int main(){ 6 double db=-12.56; 7 printf("%.2f\n",fabs(db)); 8 return 0; 9 } 1 #includ 阅读全文
posted @ 2019-07-04 11:35 kkkshiki 阅读(169) 评论(0) 推荐(0)