private void OnAttendeeConnected(object pObjAttendee)
{
IRDPSRAPIAttendee pAttendee = pObjAttendee as IRDPSRAPIAttendee;
pAttendee.ControlLevel = CTRL_LEVEL.CTRL_LEVEL_VIEW;
LogTextBox.Text += ("Attendee Connected: " + pAttendee.RemoteName + Environment.NewLine);
}

HRESULT CoCreateInstance (
REFCLSID rclsid,
LPUNKNOWN pUnkOuter,
DWORD dwClsContext,
REFIID riid,
LPVOID* ppv );

// 大数的四则运算及求模。数字无位数限制,除法的商支持小数。
#include <iostream>
#include <string>
#include <time.h> using namespace std; class BIGINTEGEROPERATIONS
{
private:
static int COMPARE(string number1, string number2)
{
int j; int length1 = number1.size();
int length2 = number2.size(); if (number1.size() == )
number1 = "";
if (number2.size() == )
number2 = ""; j = ;
for (int i = ; i < length1; ++i)
{
if (number1[i] == '')
++j;
else
break;
}
number1 = number1.substr(j); j = ;
for (int i = ; i < length2; ++i)
{
if (number2[i] == '')
++j;
else
break;
}
number2 = number2.substr(j); length1 = number1.size();
length2 = number2.size(); if (length1 > length2)
{
return ;
}
else if (length1 == length2)
{
if (number1.compare(number2) > )
{
return ;
}
else if (number1.compare(number2) == )
{
return ;
}
else
{
return -;
}
}
else
{
return -;
} return ;
} public:
static string PLUS(string number1, string number2)
{
int i; int length1 = number1.size();
int length2 = number2.size(); string result = ""; reverse(number1.begin(), number1.end());
reverse(number2.begin(), number2.end()); for (i = ; i < length1 && i < length2; i++)
{
char c = (char)(number1[i] + number2[i] - );
result = result + c;
} while (i < length1)
{
result = result + number1[i];
++i;
} while (i < length2)
{
result = result + number2[i];
++i;
} int carry = ;
for (i = ; i < (int)result.size(); ++i)
{
int value = result[i] - + carry;
result[i] = (char)(value % + );
carry = value / ;
} if (carry != )
{
result = result + (char)(carry + );
} for (i = result.size() - ; i >= ; i--)
{
if (result[i] != '') break;
} result = result.substr(, i + ); reverse(result.begin(), result.end()); if (result.length() == )
result = ""; return result;
} static string MINUS(string number1, string number2)
{
int i;
string result = ""; int length1 = number1.size();
int length2 = number2.size(); if (COMPARE(number2, number1) > )
{
return "-" + MINUS(number2, number1);
} reverse(number1.begin(), number1.end());
reverse(number2.begin(), number2.end()); for (i = ; i < length1 && i < length2; i++)
{
char c = number1[i] - number2[i] + ;
result = result + c;
} if (i < length1)
{
for (; i < length1; i++)
{
result = result + number1[i];
}
} int carry = ;
for (i = ; i < (int)result.length(); i++)
{
int value = result[i] - + carry;
if (value < )
{
value = value + ;
carry = -;
}
else carry = ; result[i] = (char)(value + );
} for (i = result.size() - ; i >= ; i--)
{
if (result[i] != '')break;
} result = result.substr(, i + ); reverse(result.begin(), result.end()); if (result.length() == ) result = ""; return result;
} static string MULTIPLY(string number1, string number2)
{
int i, j;
int *iresult;
int length1 = number1.size();
int length2 = number2.size();
string result = ""; reverse(number1.begin(), number1.end());
reverse(number2.begin(), number2.end()); iresult = (int*)malloc(sizeof(int) * (length1 + length2 + ));
memset(iresult, , sizeof(int) * (length1 + length2 + )); for (i = ; i < length1; i++)
{
for (j = ; j < length2; j++)
{
iresult[i + j] += ((number1[i] - ) * (number2[j] - ));
}
} int carry = ;
for (i = ; i < length1 + length2; i++)
{
int value = iresult[i] + carry;
iresult[i] = value % ;
carry = value / ;
} for (i = length1 + length2 - ; i >= ; i--)
{
if (iresult[i] != )break;
} for (; i >= ; i--)
{
result = result + (char)(iresult[i] + );
} free(iresult); if (result == "") result = ""; return result;
} // 缺省地,商数向下取整,floatpoint用于指定保留小数点的位数
static string DIVIDE(string number1, string number2, int floatpoint = )
{
int i, j, pos;
string result = "";
string tempstr = ""; int length1 = number1.size();
int length2 = number2.size(); if ((COMPARE(number2, number1) > ) && (floatpoint == ))
{
return "";
} tempstr = number1.substr(, length2); pos = length2 - ; while (pos < length1)
{
int quotient = ;
while (COMPARE(tempstr, number2) >= )
{
quotient++;
tempstr = MINUS(tempstr, number2);
} result = result + (char)(quotient + ); pos++; if (pos < length1)
{
tempstr += number1[pos];
}
} if (floatpoint > )
{
result += '.';
string stmp = "";
int itmp = ; for (int k = ; k < floatpoint; ++k)
{
stmp += '';
if (COMPARE(MULTIPLY(MINUS(number1, MULTIPLY(DIVIDE(number1, number2), number2)), stmp), number2) < )
{
result += '';
++itmp;
}
} string temp = DIVIDE(MULTIPLY(MINUS(number1, MULTIPLY(DIVIDE(number1, number2), number2)), stmp), number2);
if (temp[] != '') result += temp;
} j = result.size();
for (i = ; i < j; i++)
{
if (result[i] != '') break;
} result = result.substr(i, j); return result;
} static string MOD(string number1, string number2)
{
if (COMPARE(number2, number1) > )
{
return number1;
}
else if (COMPARE(number2, number1) == )
{
return "";
}
else
{
return MINUS(number1, MULTIPLY(DIVIDE(number1, number2), number2));
}
}
}; int main(int argc, char* argv[])
{
clock_t start, end; // 两个操作数均为600位
string number1 = ""
""
""
""
""
""
""
""
""
""
""
""; string number2 = ""
""
""
""
""
""
""
""
""
""
""
""; string result;
int interval = ; start = clock();
result = BIGINTEGEROPERATIONS::PLUS(number1, number2);
end = clock();
interval = (end - start) * / CLOCKS_PER_SEC; cout << "Result of PLUS operation:" << endl;
cout << result << endl;
cout << "It took " << interval << "ms" << endl;
cout << endl; start = clock();
result = BIGINTEGEROPERATIONS::MINUS(number1, number2);
end = clock();
interval = (end - start) * / CLOCKS_PER_SEC; cout << "Result of MINUS operation:" << endl;
cout << result << endl;
cout << "It took " << interval << "ms" << endl;
cout << endl; start = clock();
result = BIGINTEGEROPERATIONS::MULTIPLY(number1, number2);
end = clock();
interval = (end - start) * / CLOCKS_PER_SEC; cout << "Result of MULTIPLY operation:" << endl;
cout << result << endl;
cout << "It took " << interval << "ms" << endl;
cout << endl; start = clock();
result = BIGINTEGEROPERATIONS::DIVIDE(number1, number2);
end = clock();
interval = (end - start) * / CLOCKS_PER_SEC; cout << "Result of DIVIDE operation:" << endl;
cout << result << endl;
cout << "It took " << interval << "ms" << endl;
cout << endl; start = clock();
result = BIGINTEGEROPERATIONS::MOD(number1, number2);
end = clock();
interval = (end - start) * / CLOCKS_PER_SEC; cout << "Result of MOD operation:" << endl;
cout << result << endl;
cout << "It took " << interval << "ms" << endl;
cout << endl; return ;
} /* 计算结果如下(Release 模式): Result of PLUS operation:
1999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989997
It took 0ms Result of MINUS operation:
100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001
It took 0ms Result of MULTIPLY operation:
999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989998999899989997000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010002
It took 15ms Result of DIVIDE operation:
1.0001
It took 0ms Result of MOD operation:
100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001
It took 0ms Debug模式下,加、减、乘、除以及取模的执行时间分别为:
0ms
0ms
63ms
78ms
0ms */

void remove_duplicate(char* str)
{
if(str==NULL)
return; int len=strlen(str);
if(len<)
return; int i,j,k;
for(i=;i<len;++i)
{
for(j=i+;j<len;++j)
if(str[i]==str[j])
{
for(k=j+;k<len;++k)
{
str[k-]=str[k];
len--;
}
}
} str[len-]='\0';
}

void remove_duplicate(char* str)
{
if(str==NULL)
return; int len=strlen(str);
if(len<)
return; int i,j;
int index=;
for(i=;i<len;++i)
{
if(str[i]!='\0')
{
str[index++]=str[i];
for(j=i+;j<len;++j)
{
if(str[j]==str[i])
str[j]='\0';
}
}
}
str[index]='\0';
}

void remove_duplicate(char* str)
{
if(str==NULL)
return; int len=strlen(str);
if(len<)
return; char flags[];
int i,j;
int index=; memset(flags,,sizeof(flags));
flags[str[]]=; for(i=;i<len;++i)
{
if(flags[str[i]]!=)
{
str[index++]=str[i];
flags[str[i]]=;
}
}
str[index]='\0';
}

temporary的更多相关文章

  1. 代码的坏味道(7)——临时字段(Temporary Field)

    坏味道--临时字段(Temporary Field) 特征 临时字段的值只在特定环境下有意义,离开这个环境,它们就什么也不是了. 问题原因 有时你会看到这样的对象:其内某个实例变量仅为某种特定情况而设 ...

  2. 未能写入输出文件“c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\106f9ae8\cc0e1

    在本地开发环境没问题,但是发布到服务器出现:未能写入输出文件"c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.Ne ...

  3. App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file

    ios进行http请求,会出现这个问题: App Transport Security has blocked a cleartext HTTP (http://) resource load sin ...

  4. 转发 win7+iis7.5+asp.net下 CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files 解决方案

    win7+iis7.5+asp.net下 CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NE ...

  5. Oracle中的Temporary tablespace的作用

    临时表空间主要用途是在数据库进行排序运算[如创建索引.order by及group by.distinct.union/intersect/minus/.sort-merge及join.analyze ...

  6. 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误消息: CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\41c191fd\ff9345c5\App_Web_login.cshtml.65793277

    本地开发环境没问题,但是发布到服务器出现问题或则直接在IIS上修改东西就给我抛出以下错误: 未能写入输出文件"c:\Windows\Microsoft.NET\Framework64 \v4 ...

  7. iOS使用webView 加载网页,在模拟器中没有问题,而真机却白屏了。App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist f

    还在info.plist中配置.除了配置允许上网的配置之外,还有另一项.

  8. Oracle临时表GLOBAL TEMPORARY TABLE

    临时表:像普通表一样,有结构,但是对数据的管理上不一样,临时表存储事务或会话的中间结果集,临时表中保存的数据只对当前 会话可见,所有会话都看不到其他会话的数据,即使其他会话提交了,也看不到.临时表不存 ...

  9. iOS App TransportSecurity has blocked a cleartext HTTP (http://) resource load since it isinsecure. Temporary exceptions can be configured via your app's Info.plistfile

    “App TransportSecurity has blocked a cleartext HTTP (http://) resource load since it isinsecure. Tem ...

  10. 自己用node.js 搭建APP服务器,然后用AFNetworking 请求 报如下错误:App TransportSecurity has blocked a cleartext HTTP (http://) resource load since it isinsecure. Temporary exceptions can be configured via your app's Info.

    "App TransportSecurity has blocked a cleartext HTTP (http://) resource load since it isinsecure ...

随机推荐

  1. vim+gdb+ddd+xxgdb精彩的程序调试

    //-------------------------------------------------------------------------------------------------- ...

  2. Tsinsen A1516. fx 数位dp

    题目: http://www.tsinsen.com/A1516 A1516. fx 时间限制:2.0s   内存限制:256.0MB    总提交次数:164   AC次数:72   平均分:51. ...

  3. HDU-4115 Eliminate the Conflict 2sat

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4115 题意:Alice和Bob玩猜拳游戏,Alice知道Bob每次会出什么,为了游戏公平,Bob对Al ...

  4. UVa1449 - Dominating Patterns(AC自动机)

    题目大意 给定n个由小写字母组成的字符串和一个文本串T,你的任务是找出那些字符串在文本中出现的次数最多 题解 一个文本串,多个模式串,这刚好是AC自动机处理的问题 代码: #include <i ...

  5. SecureCRT中文乱码解决方法

    在windows下使用SecureCRT访问MAC主机,发现中文总是乱码.而且默认会话选项设置的字符编码就是UTF-8,和MAC主机默认字符编码一样. 后来通过设置,解决了中文乱码问题. 具体使用了两 ...

  6. [四]JFreeChart实践三之饼图

    饼图pie 原理总结 1.准备好要显示的数据放入dataset 2.调用ChartFactory将dataset作为参数传递进去,生成chart 3.掉Servlet工具类将chart作为参数传入生成 ...

  7. nginx + lua 构建网站防护waf(一)

    最近在帮朋友维护一个站点.这个站点是一个Php网站.坑爹的是用IIS做代理.出了无数问题之后忍无可忍,于是要我帮他切换到nginx上面,前期被不断的扫描和CC.最后找到了waf这样一个解决方案缓解一下 ...

  8. jQuery获取鼠标移动方向2

    (function($) { $.fn.extend({ show: function(div) { var w = this.width(), h = this.height(), xpos = w ...

  9. Open Dynamics Engine for Linux 安装笔记

    下载 在Bitbucket上可以下载到最新的版本(截止目前为0.14版) 或者直接用wget下载 wget "https://bitbucket.org/odedevs/ode/downlo ...

  10. Data Structure导论的导论

    DataStructure是一组互相之间存在一种或多种特定关系的数据的组织方式和它们在计算机内的存储方式,以及定义在该数据上的一组操作. 从以上定义可知,数据结构是研究数据的组织.存储方式及其操作的学 ...