找回密码
 开放注册
搜索
楼主: freeman

编程高手请进 基础C语言

[复制链接]
发表于 2011-1-23 03:48:57 | 显示全部楼层 |阅读模式
问题:

An object moving in a circular path at a constant tangential velocity V. The radial acceleration required for the object to move in a circular path is given by the equation: a = V^2 / r. Where a is the centripetal acceleration of the object in m/s^2, V is the tangential velocity of the object is m/s, and r is the turning radius in meters. Suppose that the object is an aircraft, and answer the question:

Suppose that the aircraft is moving at 85% of the speed of sound. If the centripetal acceleration is 2g, what is the turning radius of the aircraft? (Sound of speed = 340 m/s, 1g = 9.81 m/s^2)

执行范例:
Enter the speed of the aircraft (as a percentage of the speed of sound): .85
Enter the centripetal acceleration (in standard gravity): 2
The turning radius is: 289.00

我的代码如下:

#include <stdio.h>
#define SOUND 340
#define G     9.81

int main()

{
  int   inc;
  float rad;
  float vel;
  float per;
  float acc;


  printf("Enter the speed of the aircraft (as a percentage of the speed of sound): ");
  scanf("%f", &per);

  printf("Enter the centripetal acceleration (in standard gravity): ");
  scanf("%d", &inc);

  acc = G * 2;
  vel = SOUND * per;
  rad = (vel * vel) / acc;

  printf("The turning radius is: %.2f meters\n", rad);

  return (0);
}

问题:
我的程序中怎么也得不到turning radius = 289。 请大家帮我看下问题在哪里。
 楼主| 发表于 2011-1-23 04:03:11 | 显示全部楼层
啊 大家应该都睡觉了。。。
 楼主| 发表于 2011-1-23 07:35:36 | 显示全部楼层
大家快点帮忙啊 自己再顶
发表于 2011-1-23 09:44:33 | 显示全部楼层
a = V^2 / r
r是回转半径而不是你程序中的 acc向心加速度……

----
- - 我的失误……公式变形……
哎,都忘掉了呀呀呀呀……圆周运动……
发表于 2011-1-23 09:51:42 | 显示全部楼层
acc = G * 2改为acc = G * inc
单步检查一下,可能是数据类型错误~
发表于 2011-1-23 10:00:29 | 显示全部楼层
公式有误,明显得不到结果,V=17*17=289
 楼主| 发表于 2011-1-23 10:05:06 | 显示全部楼层

回 4楼(原味咖啡) 的帖子

对 这步是错了 不过改成 acc = G * inc; 还是错
 楼主| 发表于 2011-1-23 10:06:58 | 显示全部楼层

回 5楼(原味咖啡) 的帖子

我也感觉是公式错 但是我google上查来查去还是这个公式
发表于 2011-1-23 10:07:32 | 显示全部楼层
……我觉得是样例给错了吧……查了老半天公式了……
想想看,一个近乎音速的灰机在一个400x400m的房间内做匀速圆周运动,呃……

嗯,这么说吧。 2*Pi*R/(340*per)==6.28s
即灰机每6.28s完成一次圆周……
发表于 2011-1-23 10:12:39 | 显示全部楼层
G非g,在看看这。
这好像是高考里的物理送分题,当年做了不少,还有印象~
好久没写程序,都快忘了~
 楼主| 发表于 2011-1-23 10:15:21 | 显示全部楼层

回 9楼(原味咖啡) 的帖子

问题解决了

Professor发announcement说 他举例写错了
发表于 2011-1-23 10:16:52 | 显示全部楼层
引用第8楼wywzxxz于2011-01-23 10:07发表的  :
……我觉得是样例给错了吧……查了老半天公式了……
想想看,一个近乎音速的灰机在一个400x400m的房间内做匀速圆周运动,呃……

嗯,这么说吧。 2*Pi*R/(340*per)==6.28s
即灰机每6.28s完成一次圆周……
我不是指程序,是指物理概念上的G~
发表于 2011-1-23 10:21:24 | 显示全部楼层

回 10楼(freeman) 的帖子

练ACM,最好和校友组队。
我记得当时玩的时候,上北大的ACM站,是和同学一起的,这样有动力也有效率。
你发在这个论坛里很可能得不到回应,坛友大部分不是学计算机的,玩游戏和说国际的居多~
 楼主| 发表于 2011-1-23 10:31:00 | 显示全部楼层

回 12楼(原味咖啡) 的帖子

哈哈 有lab partner 但是美国人很懒 程序都是我自己写的 他们在那里看
ACM是个好地方 谢谢推荐
 楼主| 发表于 2011-1-23 10:31:44 | 显示全部楼层

回 12楼(原味咖啡) 的帖子

我也不是学计算机的 哈哈 不过工程系需要计算机
发表于 2011-1-23 13:20:05 | 显示全部楼层
圆周运动?我现在只记得活塞运动了。。。
 楼主| 发表于 2011-1-23 13:38:00 | 显示全部楼层

回 15楼(希望之星) 的帖子

其实这个公式不是最正确 飞行器在飞行中如果要改变方向的话 所形成的轨迹不是一个完美的圆周
发表于 2011-1-23 17:55:44 | 显示全部楼层
这明显不是单纯的代码问题...
发表于 2011-1-23 20:56:28 | 显示全部楼层
我明年应该要过去,还是和学校有关吧,有的学校很多人还是很勤奋的~
 楼主| 发表于 2011-1-24 04:13:07 | 显示全部楼层

回 18楼(原味咖啡) 的帖子

不是和学校有关 是和人有关。。。 我学校是普度。。。 工程系应该氛围不错 你准备去哪里?
您需要登录后才可以回帖 登录 | 开放注册

本版积分规则

Archiver|手机版|小黑屋|13号避难所-旧人类论坛

GMT+8, 2026-6-7 07:42 , Processed in 0.085544 second(s), 14 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表