随笔分类 - c语言例子
摘要:#include <stdio.h> #include <string.h> #include <stdlib.h> char* multiply(char* num1, char* num2) { int la,lb,lc,i,j; int a[2001]={0}; int b[2001]={0}
阅读全文
摘要:#include <stdio.h> #include <math.h> main() { int b,c=0,d,shu[10],f,g=4,a,e; double sum=0; for(a=100;a<=1000000000;a++) { for(e=0;e<10;e++) shu[e]=0;
阅读全文
摘要:#include <stdio.h> main() { int ap[]={3300024,200341,420034,723004,223004,234001,2300421,20,2},i,max,jiyi,shu[10]={0}; int len=sizeof(ap)/sizeof(ap[0]
阅读全文
摘要:#include <stdio.h> main() { short i=-4; printf("%d %o %x %u",i,i,i,i); getchar(); } //试卷答案为:04 177774 fffc 65532 %o %x %ushort i=-4;i 2字节-4原码:10000000
阅读全文
摘要:#include <stdio.h> main() { int a,b=2; a=(++b)+(b++); printf("%d,%d",a,b); }
阅读全文
摘要:#include <stdio.h> main() { int a=5,b=4,c=3,d=2; if(a>b>c) printf("%d\n",d); else if((c-1>=d)==1) printf("%d\n",d+1); else printf("%d\n",d+2); getchar
阅读全文
摘要:#include <stdio.h> main() { int x=4,y=4; int t=++x||++y; printf("%d %d %d\n",x,y,t); int a=1,b=1; t a&&--b; printf("%d %d %d\n",a,b,t); getchar(); }
阅读全文
摘要:#include <stdio.h> //int占用四个字节 //2的原码:00000000 00000000 00000000 00000010 //2取反后:11111111 11111111 11111111 11111101 //任何类型的数据在计算机中都是以二进制补码形式存储的 //正数的
阅读全文
摘要:#include <stdio.h> main() { int x=10,y=20,t=0; if(x==y) t=x;x=y;y=t; printf("%d %d",x,y); int n=0; while(n++<=1) printf("%d\t",n); printf("%d\n",n); /
阅读全文
摘要:#include <stdio.h> //每找到一个重复的元素,则最末尾前移一位,去重范围缩小一位 //找到重复元素后,此时数组下标之后的元素向前移一位 //程序后,数组中最右边的值是原数组最右边的值 main() { //int a[]={1,1,1,1,2,2,2,2,2,3,4,5,5,6,7
阅读全文
摘要:#include <stdio.h> main() { int a[8][8],i,j; for(i=0;i<8;i++) { a[i][0]=1; a[i][i]=1;} for(i=2;i<8;i++) for(j=1;j<i;j++) a[i][j]=a[i-1][j-1]+a[i-1][j]
阅读全文
摘要:#include <stdio.h> //为小学一年级学生随机出10道题,加法或减法随机出现,保证涉及到的数在0-9之间,结果不能出现负数 //程序运行输入结果后提示对或错,最后并统计做对了几道题,及最后得分(每题10分计算) #include <math.h> #include <stdlib.h
阅读全文
摘要:#include <stdio.h> main() { char s[]="012xy\08s34f4w2"; //ascii码0对应的字符为空字符 //本来\08可以理解为1个字符,但8不是8进制数,斜线只能转义0 //当循环到\0时,循环条件不成立,则退出循环 int i,n=0; for(i=
阅读全文
摘要:#include <stdio.h> #include <string.h> main() { char a[10]="abc",b[10]="012",c[10]="xyz"; strcpy(a+1,b+2);//b+2对应的字符2\0,结果bc改为2\0 ,所以a结果为a2 puts(strca
阅读全文
摘要:#include <stdio.h> #include <string.h> main() { char ab[100]="asdfasd",ac[100]; printf("%d %d\n",ab,ac); //ac=ab 由于ab,ac分别为两个数组的起始地址,所以该句有语法问题 //字符数组相
阅读全文
摘要:#include <stdio.h> #include <math.h> //三角函数的参数为弧度,是角度必须转化为弧度 //3.14=180,1度=3.14/180,转化方法:(3.14/180)*角度值 main() { float a,b,c; c=30; printf("%f",sin(c)
阅读全文
摘要:#include <stdio.h> main() { int a,b,c; for(a=1;a<110;a++) printf("%d ",rand()%10) ; getchar(); } 第一次运行: 第二次运行: 结果相同 一般srand和rand配合使用产生伪随机数序列。rand函数在产生
阅读全文
摘要:#include <stdio.h> //为小学一年级学生随机出10道题,加法或减法随机出现,保证涉及到的数在0-9之间,结果不能出现负数 //程序运行输入结果后提示对或错,最后并统计做对了几道题,及最后得分(每题10分计算) #include <math.h> main() { int i,a,b
阅读全文
摘要:#include <stdio.h> main() { int a,b,c,i; for(a=1;a<=9;a++) for(b=0;b<=9;b++) for(c=0;c<=9;c++) if(a*a*a+b*b*b+c*c*c==a*100+b*10+c) printf("%d ",a*100+
阅读全文
摘要:在C语言中,指针变量的值就是一个内存地址,&运算符的作用也是取变量的内存地址,请看下面的代码: #include <stdio.h> #include <stdlib.h> int a = 1, b = 255; int main(){ int *pa = &a; printf("pa = %#X,
阅读全文

浙公网安备 33010602011771号