11 12
发新话题
打印

华为面试题

华为面试题

假设一年365天,光速为350万千米/秒,写一个函数打印光一年走过多少米?
海阔,天空

TOP

又一个拿数组当数字的

TOP

又是华为的~~~
看见的,看不见了,记住的,遗忘了……

TOP

复制内容到剪贴板
代码:
//usage:distance of a lightyear
//author:zhponly
//date:20080414
//edit:none
//edition:none
//vc++6.0+windows xp
#include<iostream>
void PrintDistanceOfL(void);
using namespace std;
int main(void)
{
PrintDistanceOfL();
return 0;
}
void PrintDistanceOfL(void)
{
long unsigned int Result;    //result
unsigned int DayOfYear=365;   
unsigned int SecondsOfDay=864;    //secondsofday=864*1 00
unsigned int SpeedOfL=35;         //speedofl=35*1 0000 0000m
Result=DayOfYear*SecondsOfDay*SpeedOfL;
cout<<Result;             //less of 00 0000 0000
for(int i=0;i<10;i++)
         cout<<0;             // 00 0000 0000
cout<<endl;              //change line
}
You have to wait,until you uncovered
You have to wait,until someone naked
and then, you have to wait some more

TOP

貌似光速不是一秒35吧..............
You have to wait,until you uncovered
You have to wait,until someone naked
and then, you have to wait some more

TOP

倒不是特别特别难 就是题目太变态了 。。。

这样的题我就做不出来。。

TOP

ANSWER:可以只计算365*24*36*35保存为字符串后面在接几个0
海阔,天空

TOP

才发现 光速变了
看见的,看不见了,记住的,遗忘了……

TOP

[quote]原帖由 爱因 于 2008-4-16 19:14 发表
才发现 光速变了 [/quot



哈哈,什么都会变的,不要跟不上时代。
海阔,天空

TOP

华为总是这么bt

TOP

 11 12
发新话题