随笔分类 - c语言
摘要:#include <stdio.h> void swap(int *p1,int *p2) { int tmp=*p1; *p1=*p2; *p2=tmp; } void swap1(int *p1,int *p2){ *p1=*p1+*p2; *p2=*p1-*p2; *p1=*p1-*p2;}
阅读全文
摘要:auto:编译器在默认的缺省情况下,所有变量都是auto 的 register:register 变量必须是能被CPU 寄存器所接受的类型。意味着register 变量必须是一个单个的值,并且其长度应小于或等于整型的长度。而且register 变量可能不存放在内存中,所以不能用取址运算符“&”来获取
阅读全文
摘要:因为指针变量所对应的是地址,而整数是存放在某个地址上的内容。二者不一样
阅读全文
摘要:#include <stdio.h> main() { struct student{ char no[7]; char name[8]; int score; }; struct student st1,st2; //printf("%d\n",&student); printf("%d %d %
阅读全文
摘要:字符标志符:%cA 键盘输入:scanf("%c",&a);B 直接赋值:a='c'; 字符串(由多个字符型数据组成的一串字符)标志:%s为字符串赋值方法:A 字符串初始化:char ab[10]="asdfsdf"B 利用循环为字符数组逐个赋值: for(a=1;a<=10;a++) ab[a]=
阅读全文
摘要:#include <stdio.h> main() { int sum=0,a,b,c; for(a=1;a<=100;a++) { if(a==1) c=1; else c=0; for(b=2;b<a;b++) { if(a%b==0) { c=1; break; } } if(c==1) {
阅读全文
摘要:#include <stdio.h> main() { struct stu { int a; int b; }; struct stu ab; printf("%d",ab.a); getchar(); } int abb(struct stu ma) { } 编译时提示: 修改如下: #incl
阅读全文
摘要:#include <stdio.h> main() { int a,c=1; double sum=0,b=1.0,d,e,f; for(a=1;a<=20;a++) { d=b/(b+1); sum=sum+d; b=b+1; printf("%lf,%lf\n",b,d); } printf("
阅读全文
摘要:#include <stdio.h> main() { int x,y,z; x=0;y=z=-1; x+=-z y;//只有赋值运算符 条件运算符 求字节运算符右结合,其他都为左结合。相当于x+=-(z--)-y; //自减优先级最高先计算z--,x+=-(-1)-y //x+=1-y=1-(-1
阅读全文
摘要:#include <stdio.h> main() { struct student{ char no[8]; char name[8]; int ps; int sx; int qm; float zp; }; struct student ab[10]={ { "2020001","张三1",8
阅读全文
摘要:#include <stdio.h> struct student{ char name[12]; char number[9]; int score; }; struct student st[3]={{"zhang liang","19040301",87},{"li hong","180403
阅读全文
摘要:网络方向:技能模块 5.C语言程序设计1.技术要求(1)能够实现顺序结构的程序设计。(2)能利用if语句、switch语句实现分支结构的程序设计。 8(3)能利用while循环,do...while循环和for循环语句实现循环结构的程序设计。(4)会一维数组、二维数组的定义、初始化和数组元素引用。2
阅读全文
摘要:#include <stdio.h> main() { int a,b,c; int *e; int d[2]={0}; e=&a; printf("%d,%d\n",a,&a); printf("%d,%d\n",a,a); printf("%d,%d\n",b,&b); printf("%d,%
阅读全文
摘要://文件名o531a.c #include <stdio.h> #include "0530-1.c" main() { printf("%d",pd(2)); getchar(); } #include <stdio.h> int pd(int a) { if(a%2==0) return 1;
阅读全文
摘要:#include <stdio.h> #include <math.h> main() { int a=1003; int b,c=0,d=0,s=0;while(a) { b=a%2; s=s+b*pow(10,d); d++; a=a/2; } printf("%d",s); getchar()
阅读全文
摘要:#include<stdio.h> main() { int year,month,date,x=0,t=0; printf("请输入年份:"); scanf("%d",&year); printf("请输入月份:"); scanf("%d",&month); printf("请输入几号:"); s
阅读全文
摘要:#include <stdio.h> int gysc(int a,int b) { int c,d; for(c=1;c<=b;c++) if(a%c==0&&b%c==0) d=c; return d; } int gysa(int ys,int b) { ys=ys%b; if(!ys) re
阅读全文
摘要:#include <stdio.h> //已知任意表示时间的24小时制整数转化为12小时制时间显示,并用AM PM表示上午或下午 //如1625,2348,834,1035分别显示04:25PM 11:48PM 08:34AM 10:35AM main() { int t,h,m; t=1605;
阅读全文
摘要:#include <stdio.h> #include <math.h> #include <string.h> int pdhwd(int shu) { int a[10],i=0,b; while(shu!=0) { a[i]=shu%10; shu=shu/10; i++; } for(b=0
阅读全文
摘要:#include <stdio.h> int cf(int a) { int c=1,s=1; for(c=1;c<=a;c++) s=s*10; return s; } int pdhw(int shu) { int c=shu,a=1,b,d; while(shu) { shu=shu/cf(a
阅读全文