转换器在C ..的问题 [英] problem with Converter in C..

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

问题描述

这里的任何人都可以向我展示转换器的一些例子,如货币转换器或

通用测量转换器...我试图搜索但没有工作示例..

can anyone here show me some examples of converter like Currency converter or
universal measurement converter...i tried to search but no working example..

推荐答案

嗯,有一些规则禁止像发布完整代码,这听起来像是一个很常见的家庭作业问题。


但是,我们可以帮助你完成你的程序,你有没有开始这个?我将通过观察如何手动完成此操作来开始这一点 - 收集转换率。然后你可以为任何情况编写一个算法。转换,并从那里创建你的代码。


我会推荐谷歌的当前货币转换率,可能谷歌或维基百科的测量转换率。
Well, there are rules against doing things like posting full code, and this sounds like a pretty common homework problem.

However, we can help you with your program, have you started this? I''d start this by looking at how this is done by hand - gathering the conversion ratios. Then you can write an algorithm for an "any case" conversion, and from there create your code.

I''d recommend Google for the current currency conversion rates, and probably Google or Wikipedia for measurement conversion ratios.


问题是我不明白我的问题..

我的问题是这样的
the problem is i don''t understand my question ..
well my question is like this

问题陈述

编写一个程序,在一个单位(例如,4.5英里等)中进行测量并将其转换为另一个单位(即公里)。例如,此转换请求

450 km英里

会导致此计划输出

尝试将450.000 km转换为里程?

450.000 km = 279.6247英里

如果要求两个不同类别(例如,到卷的距离)之间的转换,程序应该产生错误消息。在接受用户交互输入的转换程序之前,程序应从输入文件中获取转换信息的数据库。用户应该能够通过名称(例如千克)或缩写(例如千克)来指定单位。
PROBLEM STATEMENT
Write a program that takes a measurement in one unit (e.g., 4.5 miles, etc) and converts it to another unit (i.e. kilometers). For example this conversion request
450 km miles
Would result in this program output
Attempting conversion of 450.000 km to miles ?
450.000 km = 279.6247 miles
The program should produce an error message if a conversion between two unit of different classes (e.g., distance to volume) is requested. The program should take a data base of conversion information from an input file before accepting conversion programs entered interactively by the user. The user should be able to specify units either by name (e.g. kilograms) or by abbreviation (e.g. kg).



算法)

the the ALGORITHM)


该程序的算法相当简单。

1

。加载测量数据库单位。

2.

获得转换价值以及新旧单位名称。

3.

重复直到遇到数据格式错误。

4.

在数据库中搜索旧单元。

5.

在数据库中搜索新单位。

6.

如果无法转换,请发出相应的消息,

7.

否则,计算和显示转换

8.

获取转换旧单位和新单位名称的价值。
The algorithm for the program is fairly straightforward.
1
. Load units of measurement database.
2.
Get value to convert and old and new unit names.
3.
Repeat until data format error encountered.
4.
Search for old unit in database.
5.
Search for new units in database.
6.
If conversion is impossible, issue appropriate message,
7.
Else, compute and display conversion
8.
Get value to convert an old and new unit names.



关于加载计量单位数据库我们需要从unit.dat fscan数据库或只是做

定义一个组的结构类型关于一个单元的所有相关属性..


单位的例子是

英里mi距离1609.3

公里公里距离1000

码yd距离0.9144

about loading units of measurement database do we need to fscan database from a unit.dat or just do
define a structure type that groups all relevant attributes about one unit..

examples of unit is
miles mi distance 1609.3
kilometers km distance 1000
yards yd distance 0.9144


好的,所以,我觉得很清楚。让我们回顾一下我们所拥有的信息:

Ok, so, it seems pretty clear to me. Let''s go over the information we have:


程序应该从输入文件中获取转换信息的数据库
The program should take a data base of conversion information from an input file



所以你在这里读文件。现在,显然,您希望以某种方式将此信息存储在您的程序中。一些数据结构需要在读取文件后保存信息,对吧?


如果要定义结构类型,那取决于你。

So you are reading a file here. Now, clearly, you want to store this information somehow in your program. Some data structure needs to hold the information after you read the file, right?

If you want to define a structure type, that''s up to you.


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

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