小编Des*_*ust的帖子

C从文件中读取多行

我遇到的问题是使用标准输入从文件中读取多行整数.文件看起来像:

123
423
235
523
..etc
Run Code Online (Sandbox Code Playgroud)

我目前的代码是:

/*
 * Read in the initial puzzle configuration.
 * Each line is 4 characters long:
 *   Row    as a character '0' .. '9'
 *   Column as character '0' .. '9'
 *   Digit  as character '0' .. '9'
 *   Terminating newline.
 * Exits with an error message if there are syntactic
 * or semantic errors with any configuration line.
 */

void configure(FILE *puzzle_file) {
        int row;
        int column;
        int value;

        while((fscanf(puzzle_file, "%i%i%i\n", row, column, …
Run Code Online (Sandbox Code Playgroud)

c scanf stdio

1
推荐指数
1
解决办法
4910
查看次数

C中的链表排序

我正在为我的一个类编写一个简单的文件,这是一个简单的链表活动,我需要对链表进行排序.

这是我到目前为止的源代码:

/*
 * Simple list manipulation exercise.
 * 1. Create a list of integers.
 * 2. Print the list.
 * 3. Sort the list.
 * 4. Print the list
 * 5. Free the list nodes.
 */

#include <stdlib.h>
#include <stdio.h>

struct node {
    int value ;
    struct node *next ;
} ;

extern struct node *mk_node(int v) ;
extern void print_list(struct node *head) ;
extern struct node *sort_list(struct node *head) ;
extern void free_list(struct node *head) ;

#define NVALUES …
Run Code Online (Sandbox Code Playgroud)

c sorting struct linked-list

1
推荐指数
1
解决办法
3万
查看次数

标签 统计

c ×2

linked-list ×1

scanf ×1

sorting ×1

stdio ×1

struct ×1