| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2612 人关注过本帖
标题:公司给的几道C语言方面的题目
只看楼主 加入收藏
andygao818
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2006-12-19
收藏
 问题点数:0 回复次数:45 
公司给的几道C语言方面的题目

QUESTION #1

The questions are based on the following scenario:

A causes B or C, but not both.

F occurs only if B occurs.

D occurs if B or C occurs.

E occurs only if C occurs.

J occurs only if E or F occurs.

D causes G, H, or both.

H occurs if E occurs.

G occurs if F occurs.

1. Answer the following questions. Watch the wording closely, and be careful about assumptions. Be sure to write down anything that may seem applicable:

a. If A occurs, which may occur?

b. If B occurs, which must occur?

c. If J occurs, which must have occurred?

d. Which may occur as a result of a cause not mentioned?

2. Write a program in C that utilizes the scenario logic to graphically (ASCII characters) depict the stated scenario. This program should take character(s) from the command line as input. Remember to write the most optimal code possible.

QUESTION #2

1. Write optimized C programs that will do the following:

a. Convert a base 16 number to its base 10 equivalent. Use 23DA as a test number.

b. Convert a base 8 number to its decimal equivalent. Use 7025 as a test number

c. How many integers from 1 to 1000 are not divisible by 8 or 12?

d. How many integers from 1 to 1000 are divisible by 6 or 8?

2. Explain why did you optimize your code this way.

QUESTION #3

1. Considering compacting memory while managing equal-sized blocks. Assume each block consists of a data field and a pointer field, and that we have marked every block currently in use. The blocks are currently located between memory locations a and b. We wish to relocate all active blocks so that they occupy contiguous memory starting at a. In relocating a block remember that the pointer field of any block pointing to the relocated block must be updated. Design an optimized C program for compacting the blocks.

QUESTION #4

1. Write a program in C to multiply two linear matrices. This program should take as input the dimensions of each matrix, as well as the components of each matrix. Remember to write the most optimal code possible. Use the following matrices as a test:

1 0

-2 3 0 6 1

5 4 3 8 -2

0 1

QUESTION #5

1. Assume that your CPU does not have multiply and divide units. You can not use function in C that will not use multiply, divide and modulo operators. Write the following programs:

a) multiply any given number by 7

b) divide any given number by 7

2. Make sure that you write the most optimized code, and give full description of any potential errors that can happen using your function.

搜索更多相关主题的帖子: C语言 
2007-07-02 23:19
andygao818
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2006-12-19
收藏
得分:0 
不好意思,好象太小了,希望路过的高手帮忙看下..............
2007-07-02 23:21
suand
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2007-6-23
收藏
得分:0 

我晕,一下就问了5道问题,还全是英文,
你牛,能翻译过来在发上来不?呵呵!

2007-07-02 23:48
andygao818
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2006-12-19
收藏
得分:0 

郁闷啊,我英语也不好的啊!!
笔试的题目,兄弟门,帮个忙啊!!!!!!!!!!!!!!

2007-07-03 00:10
windflush
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:886
专家分:0
注 册:2007-7-1
收藏
得分:0 

问题#1.
这些问题是基于下属情况的:

A发生能促使B发生或者C发生,但二者不会同时发生。
只有当B发生时才会导致F的发生。
如果B或C有一个发生了,便会导致C的发生。
只有C发生时才会导致E的发生。
只有E或F二者至少有一个发生时,J才会发生。
D能导致G的发生或者H的发生,或者G,H同时发生。
如果E发生了,H发生。
如果F发生了,G发生。

1.回答下列问题。仔细的观察这些用语,认真考虑这些假设。请写下你认为合适的东西:
a.如果A发生了,哪些事件可能发生?
b.如果B发生了,哪些事件必然发生?
c.如果J发生了,哪些事件一定已经发生了?
d.哪些事件可能由于上面未提到的一个原因发生?(这个应该是指上述未提到的逻辑吧?)

2.利用这些条件写一个C程序,用ASCII字符的表格方式来描述这个指定的条件。这个程序聪命令行接受字符串输入。记住,写出尽可能理想的代码。

问题#2
1.写出最高效的C语言程序来实现下列事情:
a.将一个16进制数转化成10进制数。请使用23DA这个数来进行测试。
b.将一个8进制数转化成相等10进制数。请使用7025这个数来进行测试。
c.从1到1000,有多少个整数不能被8或者12整除?
d.从1到1000,有多少个整数能被6或8整除?
2.解释一下,为什么你的代码这么写是最高效的?

问题#3
1.考虑在操作同等大小的块的情况下使内存紧凑。假设每个块都是由一个数据域和指针域组成,而且我们把目前正在使用的块都做了标记。这些块目前是分散在区域a和b之间。我们希望我们能把所有正在使用的块都集中起来,使他们占用一个以地址a开头的连续空间。当你改动一个块的地址的时候,注意:指向这个块的指针值也要同时被修改。设计一个高效的C程序来紧凑这些块。
(感觉就是操作系统的内存整理)

问题#4
1.写一个C程序来实现两个线性矩阵相乘(什么叫线性矩阵?忘了)。这个程序不仅将每个矩阵的内容作为输入,同时每个矩阵的分隔符也是它的输入。记住,请写出最高效的程序。使用下列矩阵作为测试数据:
1 0

-2 3 0 6 1

5 4 3 8 -2

0 1
(数据结构种的线性表相乘?)

问题#5
1.假设你的CPU没有乘法和除法单元,你也不能使用C种的乘除,取模运算符。写出下列程序:
a.用7乘以任何一个给定的数
b.用7除任何一个给定的数
2.确保你的程序是最高效的,并且对使用你的函数可能存在的错误给出详细的描述。


汗,我终于翻译完了,我今天已经没心情想题目的内容了,大家先帮忙作着吧,等明天我恢复过来了再说。

E文~~汗~


2007-07-03 01:15
andygao818
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2006-12-19
收藏
得分:0 

太感谢了................

2007-07-03 09:32
andygao818
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2006-12-19
收藏
得分:0 
各位朋友一定要帮忙做下啊,实习单位发的题目,7月7号之前要交去的,拜托了..................(在线等待)
2007-07-03 10:12
herbert_1987
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:1314
专家分:0
注 册:2007-5-13
收藏
得分:0 
呵呵, 挺不错的题目,不过我暂时不想做.

人生重要的不是所站的位置,而是所朝的方向
2007-07-03 10:23
andygao818
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2006-12-19
收藏
得分:0 

大哥帮忙做下啊!!!!!!!!!!急啊!!!!!!!!!!!

2007-07-03 10:37
酒肉弥勒佛
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:399
专家分:0
注 册:2006-6-6
收藏
得分:0 
从1到1000,有多少个整数能被6或8整除?
1000/6=166
1000/8=125
1000/24=41
所以有166+125-41=250个能给整除


从1到1000,有多少个整数不能被8或者12整除?
1000/8=125
1000/12=83
1000/24=41
所以有1000-(125+83-41)=833个不能

这个方法没有循环,自然是最高效的

不知道算法对不对

编程是为了提高效率,好的程序是因为他的高效;在编程的道路上,永远追逐高效的算法
2007-07-03 10:48
快速回复:公司给的几道C语言方面的题目
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012623 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved