我今天去接受采访,被问到这个问题:
假设您有10亿个整数在磁盘文件中未分类.你如何确定最大的一百个数字?
我甚至不确定从哪里开始这个问题.给出正确结果的最有效流程是什么?我是否需要通过磁盘文件一百次获取我的列表中尚未包含的最高数字,或者是否有更好的方法?
请看我的代码:
#include <stdint.h>
int main(int argc, char *argv[])
{
unsigned char s = 0xffU;
char ch = 0xff;
int val = 78;
((int8_t) + (78)); /*what does this mean*/
INT8_C(val); /*equivalent to above*/
signed char + 78; /*not allowed*/
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我发现宏定义<stdint.h>
是:
#define INT8_C(val) ((int8_t) + (val))
Run Code Online (Sandbox Code Playgroud)
这个加号是什么意思或含义?
这是我今天的论文测试中的一个问题,函数签名是
int is_match(char* pattern,char* string)
Run Code Online (Sandbox Code Playgroud)
图案仅限于ASCII字符和量化*
和?
,所以它是比较简单的.is_match
如果匹配则返回1,否则返回0.
我该怎么做呢?
all:这是来自Effective C++ 3rd editiion
const_cast通常用于抛弃对象的常量.它是唯一能够做到这一点的C++风格的演员.
我的问题是const_cast可以将constness添加到非const对象吗?实际上我写了一个小程序试图批准我的想法.
class ConstTest
{
public:
void test() {
printf("calling non-const version test const function \n");
}
void test() const{
printf("calling const version test const function \n");
}
};
int main(int argc,char* argv){
ConstTest ct;
const ConstTest cct;
cct.test();
const_cast<const ConstTest&>(ct).test();//it is wrong to write this statement without the '&',why
}
Run Code Online (Sandbox Code Playgroud)
省略'&'会导致以下错误:
错误C2440:'const_cast':无法从'ConstTest'转换为'const ConstTest'
它表明const_cast可以添加constness,但似乎你必须强制转换为对象引用,这个引用的魔力是什么?
所以这是一个问题:
假设你有10万个整数,范围从1到100万.请整理整数.时间复杂度应为O(n).
任何分享他或她的想法的人都非常感激.
上周我接受了采访,有一个这样的测试:
使用SHIFT LEFT,SHIFT RIGHT,ADD,SUBSTRACT指令计算N/9
(给定N
为正整数)
.
我们在代码中使用计时器,我只是对它的实际实现感到好奇,是否有计时器
CPU逻辑电路或CPU外部,例如,外部时钟或类似的东西.
如果没有,那么地狱的计时器在哪里?请帮帮我,不需要任何详细的解释
如何制作硬件定时器,只需关注我们所拥有的硬件板上的定时器.
提前致谢 .
大家好:我阅读下面的算法,找到二叉搜索树中两个节点的最低共同祖先.
/* A binary tree node has data, pointer to left child
and a pointer to right child */
struct node
{
int data;
struct node* left;
struct node* right;
};
struct node* newNode(int );
/* Function to find least comman ancestor of n1 and n2 */
int leastCommanAncestor(struct node* root, int n1, int n2)
{
/* If we have reached a leaf node then LCA doesn't exist
If root->data is equal to any of the inputs then input is …
Run Code Online (Sandbox Code Playgroud) 我在一个名为的文件中有以下内容test2.txt
.
>>> def faulty():
... yield 5
... return 7
Traceback(most recent call last):
SyntaxError: 'return' with argument inside generator(<doctest test.txt[0]>,line 3)
Run Code Online (Sandbox Code Playgroud)
我调用了测试运行python -m test2.txt
.以下结果完全超出我的预期.
我的想法是测试应该是成功的,因为我已经在我的test2.txt
文件中写了预期的输出,它"几乎"与我从控制台输出得到的相匹配.我试过添加'File "G:\"'.... line
?但测试仍然失败.
我想使用wget下载网页http://www.codeproject.com/KB/tips/ModelViewController.aspx,所以我只是使用了非常基本的命令:
wget http://www.codeproject.com/KB/tips/ModelViewController.aspx
我收到的是带有.aspx
扩展名的文件,无法在常规浏览器中正确显示.
我该如何下载该网页?