我不断得到一个整数溢出问题,我不知道如何解决它可以有人帮忙吗?edx conatins 181和eax包含174
xor eax,edx
mov edx,2
div edx
Run Code Online (Sandbox Code Playgroud) 有没有办法在不使用C中的临时变量的情况下反转链表?提前致谢.
着名的方法:
Element *reverse(Element *head)
{
Element *previous = NULL;
while (head != NULL) {
// Keep next node since we trash
// the next pointer.
Element *next = head->next;
// Switch the next pointer
// to point backwards.
head->next = previous;
// Move both pointers forward.
previous = head;
head = next;
}
return previous;
}
Run Code Online (Sandbox Code Playgroud)
使用临时变量
SAURABH
所以这是我作业中的一个问题....
假设算法的效率为n 3,如果算法中的步长需要1 ns(10 -9)秒,那么算法处理大小为1,000的输入需要多长时间?
这是我的问题:我如何解决这个问题?请不要发布答案.帮助我学习如何为自己解决这个问题.
为了在文件中搜索字符串并将匹配字符串的行写入另一个文件,对于70MB(压缩状态)的单个zip文件,需要15-20分钟.有没有办法减少它.
我的源代码:
获取Zip文件条目
zipFile = new ZipFile(source_file_name);
entries = zipFile.entries();
while (entries.hasMoreElements())
{ ZipEntry entry = (ZipEntry)entries.nextElement();
if (entry.isDirectory())
{
continue;
}
searchString(Thread.currentThread(),entry.getName(), new BufferedInputStream (zipFile.getInputStream(entry)), Out_File, search_string, stats); }
zipFile.close();
Run Code Online (Sandbox Code Playgroud)
搜索字符串
public void searchString(Thread CThread, String Source_File, BufferedInputStream in, File outfile, String search, String stats) throws IOException
{
int count = 0;
int countw = 0;
int countl = 0;
String s;
String[] str;
BufferedReader br2 = new BufferedReader(new InputStreamReader(in));
System.out.println(CThread.currentThread());
while ((s = br2.readLine()) != null)
{
str …Run Code Online (Sandbox Code Playgroud) 我一直在寻找计算数字(整数)的平方根(整数)的最快方法.我在维基百科中遇到了这个解决方案,它找到了一个数字的平方根(如果它是一个完美的正方形)或者它最近的下方完美正方形的平方根(如果给定的数字不是一个完美的正方形:
short isqrt(short num) {
short res = 0;
short bit = 1 << 14; // The second-to-top bit is set: 1L<<30 for long
// "bit" starts at the highest power of four <= the argument.
while (bit > num)
bit >>= 2;
while (bit != 0) {
if (num >= res + bit) {
num -= res + bit;
res = (res >> 1) + bit;
}
else
res >>= 1;
bit >>= 2;
}
return res;
}
Run Code Online (Sandbox Code Playgroud)
我尝试了很多测试运行来跟踪算法,但我似乎并不理解里面的部分 …
这是我的示例代码:
#include <iostream>
using namespace std;
class Base
{
public:
Base (int v, char z) {x=v;y=z;};
int x;
char y;
};
class Bar
{
public:
Bar(int m, char n):q(m),s(n),base(q,s){};
Base base;
int q;
char s;
};
int main()
{
Bar barObj(5,'h');
cout << barObj.base.x << barObj.base.y << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么我得到了输出0?
http://ideone.com/pf47j
此外,在一般情况下,什么是创造另一个类的成员对象,并调用该对象的构造正确的方法,如上面做用的对象库class Base,里面class Bar?
给我一个字符串,即"CPHBDZ".通过(按此顺序)将字母插入BST,我将:
C
/ \
B P
/ \
H Z
/
D
Run Code Online (Sandbox Code Playgroud)
如果我们将字符串的顺序更改为"CBPHDZ",我们将得到相同的树.我必须找到并列出提供相同BST的输入字符串的所有排列.我想出了如何计算这些排列的数量,但我无法弄清楚实际找到它们的任何算法.
嗨,我正在尝试用这样的语法实现一个简单语言的解析器.
program ::= "program" declarations "begin" statements "end"
declaration ::= "var" ident "as" type
type ::= "string" | "int"
Run Code Online (Sandbox Code Playgroud)
我完成了前两个,我怎么写类型语法?
program( prog( DECLS, STATS ) ) -->
[ 'program' ], declarations( DECLS ),
[ 'begin' ], statements( STATS ), [ 'end' ].
declaration( decl( IDENT, TYPE ) ) -->
[ 'var' ], ident( IDENT ), [ 'as' ], type( TYPE ).
Run Code Online (Sandbox Code Playgroud) 我导出表从SQLite到Excel中(2010年)C#.它工作正常.我正在使用这种Excel.Range.set_Value()方法.
如何格式化Excel.Range类似Excel's格式(如表格)?
如何使用DirectoryInfo.GetFilesC#中的函数找到文件类型*.gif和*.jpg ?
当我尝试这段代码时:
string pattern = "*.gif|*.jpg";
FileInfo[] files = dir.GetFiles(pattern);
Run Code Online (Sandbox Code Playgroud)
例外"路径中的非法字符".被扔了.
algorithm ×2
c# ×2
assembly ×1
bit-shift ×1
c ×1
c++ ×1
class ×1
constructor ×1
directory ×1
file ×1
file-io ×1
filter ×1
formatting ×1
java ×1
linked-list ×1
object ×1
parsing ×1
performance ×1
permutation ×1
prolog ×1
search ×1
square-root ×1
x86 ×1