| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2612 人关注过本帖
标题:公司给的几道C语言方面的题目
只看楼主 加入收藏
li4pug
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-7-6
收藏
得分:0 
turbo c2.0在切换或退出时老是死机,是turbo c2.0死了,不是机器死了,怎么回事,请高手详细指点,跪谢!
2007-07-06 22:30
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
以下是引用chinahgcq在2007-7-6 13:33:23的发言:

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.


For 1(a)
typedef ElemType int;
#define NUM 7;
ElemType Multiply(ElemType Num,ElemType n)
{
ElemType Result;
for(int i=0;i<NUM;i++)
{
Result +=n;
}
return Result;
}

then the result is NUM*n,but this methord is not good,as it's not fast,lets try another one;

ElemType Multiply(ElemType NUM,ElemType n)
{
ElemType Result,n1,n2;
n1=n<<3; //that's n1=n*8;
n2=n; //that's n2=n*1;
Result=n1-n2; //that's Reuslt=n*8-n*1=7*n;

return Result;
}



For 1(b),it's the same


这个方法有点难想出来.
尤其是在做除法的时候.
果然厉害


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

谢谢楼上的各位........学到不少东西..........
难道这到题目就没有人会做吗??


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

2007-07-07 12:05
chinahgcq
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2007-6-4
收藏
得分:0 
不是不会做,你上面写的线性矩阵的写法让人摸不着头脑 ,把它写清楚点,用两个式子分别表示出来,不要写在一块

2007-07-07 16:44
w362034710
Rank: 1
等 级:新手上路
帖 子:169
专家分:0
注 册:2006-12-2
收藏
得分:0 
第一题跟自动机接收合法字符差不多道理,,学过编译原理都知道怎么做,,

最后一题明显就是用位移运算,(鄙人的第一反应)
2007-07-07 22:28
静夜嘶
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2007-7-2
收藏
得分:0 

我刚才还以为进了一个打开错误的网页呢


2007-07-08 02:47
快速回复:公司给的几道C语言方面的题目
数据加载中...
 
   



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

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