出于某种原因,我的代码能够比双整数更快地执行双向交换.我不知道为什么会发生这种情况.
在我的机器上,双交换循环比整数交换循环快11倍.双打/整数的哪些属性使它们以这种方式执行?
测试设置
输出:
Process time for ints 1.438 secs
Process time for doubles 0.125 secs
#include <iostream>
#include <ctime>
using namespace std;
#define N 2000000000
void swap_i(int *x, int *y) {
int tmp = *x;
*x = *y;
*y = tmp;
}
void swap_d(double *x, double *y) {
double tmp = *x;
*x = *y;
*y = tmp;
}
int main () {
int a = 1, b = …Run Code Online (Sandbox Code Playgroud) 我一直试图在c#中解析这个xml
<schema uri=http://blah.com/schema >
<itemGroups>
<itemGroup description="itemGroup1 label="itemGroup1">
<items>
<item description="The best" itemId="1" label="Nutella"/>
<item description="The worst" itemId="2" label="Vegemite"/>
</items>
</itemGroup>
</itemGroups>
</schema>
\itemGroup1\Nutella-The best
\itemGroup1\Vegemite-The worst
Run Code Online (Sandbox Code Playgroud)
任何帮助或方向将不胜感激.