摘要: 卷 阅读全文
posted @ 2023-01-11 21:35 码羊 阅读(9) 评论(0) 推荐(0)
摘要: day 1 阅读全文
posted @ 2023-01-01 13:31 码羊 阅读(10) 评论(0) 推荐(0)
摘要: 对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 int fun(int n) 3 { 4 int i; 5 for(i=2;i<n;i++) 6 if(n%i==0) 7 return 0; 8 return 1; 9 } 10 int main() 11 { 12 int cou 阅读全文
posted @ 2022-09-20 20:57 码羊 阅读(63) 评论(0) 推荐(0)
摘要: 模拟翻牌过程即可,利用二维思想模拟即可 代码如下,详情请看注释 1 #include<stdio.h> 2 int fun(int *a)//定义一个翻牌过程函数(时刻记住c语言是面向过程的语言) 3 { 4 for(int i=2;i<52;i++)//从翻倍数为2的牌一直翻到倍数为51的牌,倍数 阅读全文
posted @ 2022-09-20 09:03 码羊 阅读(112) 评论(0) 推荐(0)
摘要: 有五个数12,-1,66,5,7,选出最大的的数的下标,把最大的数与最后的位置交换,5个数找4次最大的数即可 代码如下 1 #include<stdio.h> 2 #include<math.h> 3 int main(){ 4 int a[5]={12,-1,66,5,7}; 5 int len= 阅读全文
posted @ 2022-09-18 12:06 码羊 阅读(18) 评论(0) 推荐(0)
摘要: 假设有5个数12,-1,66,5,7 解:存进一个长度为5的数组,依次比较前后两项,前<后即可交换 代码如下 1 #include<stdio.h> 2 int main(){ 3 int a[5]={12,-1,66,5,7}; 4 int len=5; 5 int b; 6 for(int k= 阅读全文
posted @ 2022-09-18 12:04 码羊 阅读(64) 评论(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 码羊 阅读(172) 评论(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 码羊 阅读(49) 评论(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 码羊 阅读(22) 评论(0) 推荐(0)