我们应该问...... [英] should we ask the ..

查看:48
本文介绍了我们应该问......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们应该询问用户的项目名称,代码,价格,数量并将其显示为表格吗?

should we ask the item name , code, price , quantity from user and display it like a table?

推荐答案

我将您的问题解释为如何询问...。在这种情况下,您最好先做一些伪代码方法,以便决定要完成的任务。然后开始用实际语言实现 - 在这种情况下为C.

可能的方法是:
I interpret your question as "How to ask...". In this case, you best do some pseudo-code approach first to make up your mind on the task to do. Then start to implement in the actual language - C in this case.
A possible approach was:
1. read all entries into list or an array
2. display the read data as table

读取所有条目可能是这样的:

Reading all entries might be something like this:

define an entry as a record (or struct in C) with elements:
- name     --> e.g. as fixed size array of characters
- code     --> e.g. as fixed size array of characters
- price    --> e.g. as C double value
           --> or as unsigned int value of the smallest currency unit
- quantity --> e.g. as unsigned int value

define the list of records as a fixed size array of entries (array[0...N-1])
--> this is the simplest approach in C

max number of entries = number of reserved entries in the array (= N)
current record index = 0
while (current record index < max number of entries) loop
    if (read record(array[current record index])) then
        increment current record index
    else
        break loop
    end if
end loop
number of read records = current record index + 1

以表格格式写入记录可能是

Writing the records in tabular format might be

write title row
current record index = 0
while (current record index < number of read records) loop
    write data row for array[current record index]
    increment current record index
end loop

转换为C留作练习。

干杯

Andi

Transforming into C is left as exercise.
Cheers
Andi


这篇关于我们应该问......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆