随笔分类 - c语言
摘要:用户输入两个正整数,第一个代表头数,第二个代表脚数,计算鸡和兔的数量,若无解输出Error #include <stdio.h> main() { int a,b,j,t; scanf("%d%d",&a,&b);//头数 脚数 j=(4*a-b)/2;//头数的4倍(鸡的4倍相当于鸡的脚数的2倍,
阅读全文
摘要:#include <stdio.h> /* 身份证号码是由18位数字组成的,他们分别表示: 1、前1、2位数字表示:所在省份的代码。 2、前3、4位数字表示:所在城市的代码。 3、前5、6位数字表示:所在区县的代码。 4、第7~14位数字表示:出生年、月、日,7、8、9、10位是年,11、12位是月
阅读全文
摘要:char a='9'; int b=a-'0'; printf("%d",b); 结果:9
阅读全文
摘要:#include <stdio.h> main() { int n=10,a=1,b=1,c; for(a>0;a<3;a++) for(b>0;b<3;b++) c=n-a; printf("%d %d",a,c); getchar(); }
阅读全文
摘要:#include <stdio.h> //任意鸡兔同笼问题 main() { int a,b,ji,tu,d=0; scanf("%d%d",&a,&b); for(ji=0;ji<=a+b;ji++) { for(tu=0;tu<=a+b;tu++) { if(ji+tu==a && 2*ji+t
阅读全文
摘要:#include <stdio.h> //n个硬币,甲(Rui)乙(Seven)两人轮流取硬币,每次最少取1个,最多取3个 。甲先取,取走最后1个硬币者获胜; //甲乙都能做出最佳选择的情况下,输赢只与硬币数量n有关。编程任意n个硬币,如果甲赢输出"Rui",乙赢输出"Seven" //每个人都想最
阅读全文
摘要:#include <stdio.h> #include <time.h> // time_t数据类型,日历时间头文件 int main(void) { int year,month,day,n,y,r,zhou; time_t current = time(NULL); // 利用time函数获取日
阅读全文
摘要:#include <stdio.h> int gygb(int m,int n,int x) { int a; if(x==0) { for(a=m;a>=1;a--) if(m%a==0 && n%a==0) return a; return a; } else { for(a=m;a<m*n;a
阅读全文
摘要:#include <stdio.h> #include <string.h> struct data {char name[7];int age;} ab[5]={"张三",10,"李四",11,"张五",12,"李六",13,"陈七",14}; //编程将数组中所有姓张的年龄增加1,姓李的增加2,
阅读全文
摘要:#include <stdio.h> struct data {char name[7];int age;} ab[5]={"张三",10,"李四",11,"张五",12,"李六",13,"陈七",14}; //编程将数组中所有姓张的年龄增加1,姓李的增加2,然后输出各个人的姓名与年龄 //中文字符
阅读全文
摘要:#include <stdio.h> #include <time.h> int main () { time_t tt;//typedef long time_t;time_t实际上是long型,从一个时间点(一般是1970年1月1日0时0分0秒)到当前的秒数。 time(&tt); //获取秒数
阅读全文
摘要:#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 //任何类型的数据在计算机中都是以二进制补码形式存储的 //正数的
阅读全文