摘要: 1.malloc()函数 原型: void *malloc(unsigned size) 其功能是在内存的动态存储区中分配长度为size个字节的连续空间。 其返回值= 1).分配空间的起始地址(分配成功) 2).空指针NULL(分配失败,一般是没有空间) 2.free(p)函数 该函数表示释放由p指 阅读全文
posted @ 2018-09-28 16:15 唉蒙程灵素 阅读(344) 评论(0) 推荐(0) 编辑
摘要: 函数的一般定义形式为: 存储类型标识符 类型标识符 函数名(形式参数表列及类型说明) { 说明部分 语句部分 } 存储类型标识符:static和extern两种 类型标识符:(说明函数的返回值类型) 可以是任何基本类型,结构体型,指针型。到那时不能是数组。 函数名:一个标识符 特别要注意函数的类型标 阅读全文
posted @ 2018-09-28 15:24 唉蒙程灵素 阅读(390) 评论(0) 推荐(0) 编辑
摘要: 如 3+4+5+6+7等 #include <stdio.h>void addres(int x,int y){ int i; int sum=0; for(i=x;i<=y;i++) { sum=sum+i; } printf("%d",sum);}void main(){ int a,b; pr 阅读全文
posted @ 2018-09-16 22:54 唉蒙程灵素 阅读(530) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <string.h>void main(){ struct staff { char name[20]; char department[20]; int salary; int cost; }worker[3]= { {"Xu_Guo","pa 阅读全文
posted @ 2018-08-20 19:18 唉蒙程灵素 阅读(292) 评论(0) 推荐(0) 编辑
摘要: //判断一个数是不是素数#include <stdio.h>int main(){ int t; while(1) { scanf("%d",&t); int i,x,z=0; for(i=1;i<t;i++) { x=t%i; if(x==0) z++; } if(z<2) printf("该数是 阅读全文
posted @ 2018-08-18 16:42 唉蒙程灵素 阅读(203) 评论(2) 推荐(0) 编辑
摘要: #include <stdio.h>#include <conio.h>void main(){ struct stuscore { char name[20]; float score[5]; float average; }x; int i; float sum; char rep; while 阅读全文
posted @ 2018-08-17 19:42 唉蒙程灵素 阅读(597) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>int main(int argc, char const *argv[]){ int number; int i; int*a; scanf("%d",&number); //int a[number]; a=malloc( 阅读全文
posted @ 2018-08-16 16:36 唉蒙程灵素 阅读(267) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int main(){ int x; scanf("%d",&x); int t; int ret=0;do { t=x%10; ret=ret*10+t; x/=10; }while(x>0); printf("%d",ret);} 阅读全文
posted @ 2018-08-15 19:06 唉蒙程灵素 阅读(243) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <time.h>int main(){ int x,n=0; srand(time(0)); int number=rand()%100; //printf("%d\n",&number); printf(" 阅读全文
posted @ 2018-08-15 16:51 唉蒙程灵素 阅读(137) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int main(){ long int t,x,y,ret=0; printf("底和真数:\n"); scanf("%d%d",&x,&y); t=y; while(y>x) { y/=x; ret++; } printf("log %d of %d is % 阅读全文
posted @ 2018-08-15 15:24 唉蒙程灵素 阅读(460) 评论(0) 推荐(0) 编辑