锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
typedef struct LNode
{
int data;
LNode *next;
}LNode ;
typedef LNode* LinkList;
//鍗曢摼琛ㄦ湁鐜繑鍥瀟rue 鍚﹀垯榪斿洖false
bool is_looplist(LNode *head)
{
LNode *fast,*slow;
if (head == NULL || head->next == NULL)
{
return false;
}
slow = head;fast = head->next;
while(true)
{
if(!fast || !fast->next)
return false;
//涓轟簡闃叉fast璺ㄨ繃slow鐨勬儏鍐碉紝鍦ㄦ瘡嬈″垽鏂殑鏃跺欐瘮杈冨綋鍓嶈妭鐐瑰拰涓嬩竴鑺傜偣
else if (fast == slow || fast->next == slow)
return true;
else
{
slow = slow->next;//涓嬈¤煩涓姝?/span>
fast = fast->next->next;//涓嬈¤煩涓ゆ
}
}
}
#include <iostream>
using namespace std;
//startPos 鏈澶у拰瀛愭暟緇勭殑璧峰浣嶇疆
//endPos 鏈澶у拰瀛愭暟緇勭殑緇撴潫浣嶇疆
int MaxSum(int *A,int n,int &startPos,int &endPos)

{
int tmpStart = 0;
int nStart = A[0];
int nAll = A[0];
for (int i=1;i<n;i++)
{
if(nStart < 0)
{
nStart =0;
startPos = i;
}
nStart += A[i];
if (nStart>nAll)
{
nAll = nStart;
endPos =i;
tmpStart = startPos;
}
}
startPos = tmpStart;
return nAll;
}
int main()

{
int arr[11] =
{-2,5,6,-6,4,-8,6,3,-1,2,-9};
int startP = 0,endP = 0;
int maxsubArrSumValue =0;
maxsubArrSumValue = MaxSum(arr,11,startP,endP);
cout<<maxsubArrSumValue<<endl<<startP+1<<endl<<endP+1<<endl;
system("pause");
return 0;
}
bool prime (int num)

{
if (num == 2 || num == 3 || num == 5)
return true;
if (num % 2 == 0 || num % 3 == 0 || num % 5 == 0 || num == 1)
return false;
unsigned long c = 7;
int maxc = int (sqrt (num));
while (c <= maxc)
{
if (num % c == 0)
return false;
c += 4;
if (num % c == 0)
return false;
c += 2;
if (num % c == 0)
return false;
c += 4;
if (num % c == 0)
return false;
c += 2;
if (num % c == 0)
return false;
c += 4;
if (num % c == 0)
return false;
c += 6;
if (num % c == 0)
return false;
c += 2;
if (num % c == 0)
return false;
c += 6;
}
return true;
}
unsigned long sTime,eTime;
double dTime;
sTime = click();
/**////TODO
eTime = click();
dTime = (double)(eTime-sTime)/CLOCKS_PER_SEC;
inline unsigned __int64 GetCycleCount() 
{
__asm RDTSC
}
inline unsigned __int64 GetCycleCount() 
{
__asm _emit 0x0F
__asm _emit 0x31
}
#include <iostream>
#include <Windows.h>
using namespace std;
inline unsigned __int64 GetCycleCount() 

{
__asm _emit 0x0F
__asm _emit 0x31
}
int main()

{
unsigned long t;
t = (unsigned long)GetCycleCount();
Sleep(1000);
t = (unsigned long)GetCycleCount() - t;
cout<<"鏃墮棿錛?/span>"<<t<<endl;
system("pause");
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main()

{
//a寰呰緭鍏ョ殑寮騫蟲柟鏍規(guī)暟
//x 閫夊彇鐨剎0鐐?br>
//y 姣忔榪唬鐨勪腑闂村?/span>
double a, x,y;
unsigned long start,endt;
cin>>a;
LARGE_INTEGER t1,t2,tc;
QueryPerformanceFrequency(&tc);
printf("Frequency:%u\n",tc.QuadPart);
QueryPerformanceCounter(&t1);
if (a<0)
cout<<"璐熸暟娌℃湁騫蟲柟鏍癸紒"<<endl;
else
{
x = 1;
y = (x+a/x)/2;
while (x!=y)
{
x = y;
y = (x+a/x)/2;
}
}
QueryPerformanceCounter(&t2);
printf("Lasting Time:%u\n",(t2.QuadPart-t1.QuadPart));
//duration = (double)(finish - start)/CLOCKS_PER_SEC ;
cout <<a<<"鐨勫鉤鏂規(guī)牴涓猴細(xì)"<<x<<endl;
QueryPerformanceCounter(&t1);
sqrt(a);
QueryPerformanceCounter(&t2);
printf("Lasting Time:%u\n",(t2.QuadPart-t1.QuadPart));
cout<<a<<"鐨勫鉤鏂規(guī)牴涓猴細(xì)"<<sqrt(a)<<endl;
system("pause");
return 0;CString.format("%s",string.c_str());
UNICODE緙栫爜錛?br>CString inStr;
setlocale(LC_ALL,"chs");
char* p = new char[...];//瓚沖闀?br>wcstombs( p , str , str.GetLength() );
string outStr = p;
ASCII緙栫爜錛?br>CString inStr;
string outStr = (const char*)str;
CSstring.format("%s",char*);
CString strtest;
char * charpoint;
charpoint=strtest.GetBuffer(strtest.GetLength());
string s(char*);
char *p = string.c_str();
銆奀++鏍囧噯鍑芥暟搴撱嬩腑璇寸殑
鏈変笁涓嚱鏁板彲浠ュ皢瀛楃涓茬殑鍐呭杞崲涓哄瓧絎︽暟緇勫拰C鈥攕tring
1.data(),榪斿洖娌℃湁”\0“鐨勫瓧絎︿覆鏁扮粍
2,c_str()錛岃繑鍥炴湁”\0“鐨勫瓧絎︿覆鏁扮粍
3錛宑opy()
CString ss="1212.12";
int temp=atoi(ss);
//CString aaa = "16" ;
//int int_chage = atoi((lpcstr)aaa) ;
CString aa;
aa.Format("%d",temp);
Format鍑芥暟鐨勫姛鑳藉緢寮猴紝濂藉ソ鐮旂┒涓涓嬨?br>
int a = 2;
char p[NUM];//NUM澶熺敤
string desStr = itoa(a,p,10)//絎笁涓弬鏁板緢鏈夋剰鎬濓紝榪欓噷鐨?0浠h〃鐨勬槸10榪涘埗錛屽鏋滀綘鐨勪緥瀛愪腑 a =10 ,itoa(a,p,16)鐨勮瘽錛宒esStr = "a";
string srcStr= "222";
int a = atoi(srcStr);