![](https://img-blog.csdnimg.cn/20190927151117521.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
c课后题
红皮书第五版课后题
sumi№
这个作者很懒,什么都没留下…
展开
-
行列互换
#include<stdio.h> int **transform(int **arry, int row_count, int col_count) { //列变行,行变列,则行的个数是以前列的个数,列的个数是以前行的个数 int **p = NULL; //矩阵中有多少行,取决于以前有多少列,然后申请地址空间 p = (int **)malloc(sizeof(int *) * col_count); for (int i = 0; i < col_count; i++) { //一行原创 2021-12-01 07:46:19 · 767 阅读 · 0 评论 -
13个人围成环,123报数 报到3的人退出,最后剩一人结束。用链表实现
#include <stdio.h> #define NUM 13 typedef struct people { int num; struct people *next; } people; int main() { int count = NUM; people p[NUM]; people *head; head = p; //head 指向p[0] //1~13编号 for (int i = 0; i < NUM; i++) { head->num = i + 1; hea原创 2021-11-26 08:55:43 · 241 阅读 · 0 评论 -
一数组10个元素,将最大值放最后,最小值放开头,写三个函数分别实现输入 换值 输出。(老是出错,终于可以了,做个笔记)
#include <stdio.h> void input(int *arry, int len) { for (int i = 0; i < len; i++) { scanf("%d", &arry[i]); } } void print(int *arry, int len) { for (int i = 0; i < len; i++) { printf("%d “, arry[i]); } printf(”\n"); } void handle(int *arry,原创 2021-11-26 08:15:49 · 763 阅读 · 0 评论 -
n个数 向后移动m位
#include <stdio.h> void move(int *arry, int n, int m) { int end_idx = n - m;//找到倒数第m个数据的位置,也就是要移动到数组首部的数据的起始位置 for (int i = 0; i < m; i++) { int *p = arry + n-1;//从倒数第m个数据的位置开始逐渐向后偏移直到数组尾部 int tmp = *p;//获取到这个位置的值,用于数组前边数据向后偏移1位之后,向数组第i位赋值 for (in原创 2021-11-25 08:09:59 · 536 阅读 · 0 评论