比较数组与世界纪录 [英] comparing arrays to World Record

查看:63
本文介绍了比较数组与世界纪录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C语言。提示用户输入相应的现场活动,他们的个人最佳时间和个人最佳时间将与世界记录进行比较。



我要写一个代码来确定最接近世界纪录的运动员的TRN。



我将如何做到这一点。这就是我到目前为止:



 main()
{
float pbdiff [ 10 ],WR [n];
int max = 0 ,min = 999999999 ;

// 以前输入的WR。

for (q = 0 ; q< n;> pbdiff [q] = WR [q] - perbest [q];
if (pbdiff [q]> max){
max = pbdiff [q];}
if (pbdiff [q]< min){
min = pbdiff [q];}
}
printf( %d的个人最佳成绩%.2f最接近世界纪录\ n,trn [q ],WR [q] -min);


return 0 ;
}

解决方案

首先查看任务,然后制定一系列步骤更简单,更容易孤立地做。

然后看看那些,并将它们分解为小ler步骤,等等。最终,步骤将非常简单,您可以直接实施它们,测试它们,然后继续下一步。通过简单的小步骤,您可以执行较大的步骤,等等,直到整个程序完成。



例如,您可以将此任务分解为5阶段:

1)从存储它的任何地方读取现有记录数据。

2)读取用户事件和时间。

3)比较用户针对世界记录的数据。

4)显示输入和记录数据。

5)更新记录数据存储。



然后看看第一阶段,看看涉及到什么。

这并不复杂:它只是意味着你坐下来思考它,计划你如何做,然后得到它编码和测试。



这是你的作业,而不是我们的作品:所以继续吧! :笑:

I am using C language. The user is prompted to enter for respective field events, their personal best times and this personal best time will be compared with World Record.

I am to write a code that will determine the TRN of the athlete closest to the world record.

How would I go about doing this. This is what I have so far:

main()
{
float pbdiff[10], WR[n];
int max=0, min=999999999;

//WR previously entered.

for(q=0; q<n;>            pbdiff[q] = WR[q]-perbest[q];
            if (pbdiff[q] > max){
                max = pbdiff[q];}
            if (pbdiff[q] < min){
                min = pbdiff[q];}
             }
            printf("%d has a personal best of %.2f  closest to the World Record\n", trn[q], WR[q]-min);


return 0;
}

解决方案

Start by looking at the task, and working out a series of "steps" that are simpler and easier to do in isolation.
Then look at those, and break them into smaller steps, and so on. Eventually, the steps will be so easy you can implement them directly, test them, and move on to the next step. By doing the small easy steps, you do the bigger ones, and so forth, until the whole program is complete.

For example, you could break this task into 5 stages:
1) Read existing record data from wherever you store it.
2) Read user events and times.
3) Compare user data against world records.
4) Display the input and record data.
5) Update the record data store.

Then look at the first stage, and see what is involved.
This isn't complex: it just means you sit down and think about it, plan how you do it and then get into coding and testing.

It's your homework, not ours: so get on with it! :laugh:


这篇关于比较数组与世界纪录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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