随笔分类 -  c编程题

摘要:对malloc函数的运用 问题:开辟一段动态内存空间,存入学生的姓名,年龄和成绩 设有n个62字节的空间,前50字节用来存姓名,51-54用来存年龄,55-62用来存成绩即可 代码如下 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main(void) 阅读全文
posted @ 2022-09-21 19:27 码羊 阅读(19) 评论(0) 推荐(0)
摘要:代码如下 1 #include<stdio.h> 2 float f(float x,int n){//定义x的n次幂 3 4 float s; 5 if(n==1)s=x; 6 else if(n>1) 7 { 8 s=x*f(x,n-1);//x乘上x的n-1次幂 9 } 10 return s 阅读全文
posted @ 2022-09-13 21:10 码羊 阅读(186) 评论(0) 推荐(0)
摘要:此题简单 代码如下 #include<stdio.h> #include<math.h> float f1(float x) { float f; f=pow(x,41)+pow(x,3)+1; return f; } float f2(float x) { float f; f=41*pow(x, 阅读全文
posted @ 2022-09-12 20:58 码羊 阅读(54) 评论(0) 推荐(0)
摘要:此题简单,代码如下,无注释 1 #include<stdio.h> 2 int f(int a) 3 { 4 int b,t=-1; 5 while(a){ 6 b=a%10; 7 if(t>b) 8 return 0; 9 t=b; 10 a=a/10; 11 } 12 return 1; 13 阅读全文
posted @ 2022-09-11 21:18 码羊 阅读(33) 评论(0) 推荐(0)
摘要:此题异常简单,代码如下,无注释 #include<stdio.h> #include<math.h> float hs(int a,int b,int c){ float s; s=(4.25*(a+b)+log(a+b+sqrt(a+b)+1/(a+b)))/(4.25*c+log(c+sqrt( 阅读全文
posted @ 2022-09-10 18:49 码羊 阅读(33) 评论(0) 推荐(0)
摘要:代码如下//解析看注释即可 1 #include<stdio.h> 2 int main(){ 3 int a[5][5]={{11,4,2,7,8},{5,9,23,1,25},{3,22,21,18,15},{17,16,24,12,6},{13,10,19,20,14}};//定义如图所示的二 阅读全文
posted @ 2022-09-09 17:10 码羊 阅读(64) 评论(0) 推荐(0)
摘要:此题异常简单 代码如下 1 #include<stdio.h> 2 int main(){ 3 int a,b,t; 4 char c; 5 printf("请输入两个操作数和一个运算符\n"); 6 scanf("%d%c%d",&a,&c,&b); 7 printf("%d%c%d\n",a,c 阅读全文
posted @ 2022-09-09 15:58 码羊 阅读(356) 评论(0) 推荐(0)
摘要:简单的递归调用即可(注释提及) 代码如下 1 #include<stdio.h> 2 #include<stdlib.h> 3 float qbxf(int n,float x)//定义切比雪夫多项式 4 { 5 float s;//定义float型s,用来存放qbxf 6 if(n==0){ 7 阅读全文
posted @ 2022-09-08 21:58 码羊 阅读(279) 评论(0) 推荐(0)