gpt4 book ai didi

c - 基本 C 操作

转载 作者:行者123 更新时间:2023-11-30 19:20:51 24 4
gpt4 key购买 nike

我有一个我遇到的任务。我将首先介绍它的描述和要求,然后指出我在处理时遇到的问题。

Build a block scheme and a program that reads another C-based program and finds:

  • 程序中的行数
  • 条件运算符 if 和 if/else 的数量

    程序需要从包含以下选项的菜单启动:

    • Reading the program from a file and storing the result in a separate file (the user has to input the names of both files whilst the program file has to end in “.C”)
    • Reading the program from a file and outputting the result on the screen (the user selected file has to end in “.C”).
    • Reading of the program from the keyboard and inserting a file selected by the user;
    • Reading of the program from the keyboard and outputting on the screen; The program has to be written in different functions for each operation.

    文件的读取必须逐行完成。

第一个问题是什么是 block 方案以及“从键盘读取”指的是什么?

提前致谢

最佳答案

block 方案是 block diagram 的另一个术语,尽管很少使用。 ,或流程图。

框图是:

a diagram of a system in which the principal parts or functions are represented by blocks connected by lines that show the relationships of the blocks.

或者换句话说,这是一种在编写任何代码之前使用笔和纸构建程序流程的方法。通常,他们使用一组形状来表示某些事物,圆形/椭圆形可以显示状态/开始/结束,矩形可以代表函数,菱形可以用于决策点,等等。

当您询问特定的作业问题时,最好澄清老师的期望,但程序的 block 方案的快速示例可能类似于:

enter image description here

对于你的导师想要的东西来说,这可能太算法化了,他们可能只想看到只显示“从用户处获取输入”“打开文件”的 block ,显示在模块级别流动并忽略检查错误条件时的决策细节。

现在就“从键盘读取程序”而言,由于我没有写作业,这又是猜测,但我很确定你的老师只是说得到通过 stdin 输入。该机制取决于您在类里面学习的内容,但在 C 语言中,就像 scanf() 一样。或fgets()或者任何你知道可以从键盘获取输入的东西。

关于c - 基本 C 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20999634/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com