#include
#include
#include
2008年10月30日 星期四
ACM100: The 3n + 1 problem
#include
using namespace std;
class n3plus1
{
public:
int GetMaxCycle(int i,int j)
{
int max=0;
int temp;
for(;i<=j;++i)
{
temp=GetCycle(i,0);
max=temp>max?temp:max;
}
return max;
}
int GetCycle(int n,int temp)
{
++temp;
if(n==1)
{
return temp;
}
else if(n%2==0)
{
return GetCycle(n/2,temp);
}
else
{
return GetCycle(n*3+1,temp);
}
}
};
int main(int argc, char *argv[])
{
int m,n,max,min;
n3plus1 obj;
while(true)
{
cin >> m >> n;
if(cin.eof())
{
break;
}
max=m>n?m:n;
min=mcout << m << " " << n << " " << obj.GetMaxCycle(min,max) << endl;
}
}
ACM476: Points in Figures: Rectangles
#include
#include
#include
using namespace std;
class Point
{
public:
Point(float xx,float yy):x(xx) , y(yy){};
float x,y;
};
class Rectangle
{
public:
Point point1,point2;
Rectangle(float x1,float y1,float x2,float y2):point1(x1,y1),point2(x2,y2){};
bool IsIn(Point point)
{
return point.x > point1.x && point.x < point2.x && point.y < point1.y && point.y > point2.y;
}
};
class ACM476
{
public:
vectorrectangles;
vectorpoints;
};
int main(int argc, char *argv[])
{
ACM476 acm476;
while(true)
{
string input;
getline(cin,input);
istringstream ss;
ss.str(input);
string cmd;
float x1,y1,x2,y2;
ss >> cmd;
if(cmd=="*")
{
break;
}
switch(cmd[0])
{
case 'r':
ss >> x1;ss >> y1;ss >> x2;ss >> y2;
acm476.rectangles.push_back(Rectangle(x1,y1,x2,y2));
break;
}
}
while(true)
{
string input;
getline(cin,input);
istringstream ss;
ss.str(input);
float x,y;
ss >> x;
ss >> y;
if(x==9999.9f && y==9999.9f)
{
break;
}
acm476.points.push_back(Point(x,y));
}
for(vector::size_type ip =0;ip != acm476.points.size();++ip)
{
bool flag=false;
for(vector::size_type ir =0; ir != acm476.rectangles.size();++ir)
{
if(acm476.rectangles[ir].IsIn(acm476.points[ip]))
{
cout << "Point " << ip+1 << " is contained in figure " << ir+1 << endl;
flag=true;
}
}
if(!flag)
{
cout << "Point " << ip+1 <<" is not contained in any figure" << endl;
}
}
}
ACM458 - The Decoder
#include
using namespace std;
int main(int argc, char *argv[])
{
string input;
int cmt;
int i;
while(true)
{
cin >> input;
if(cin.eof())
{
break;
}
cmt=input.size();
for(i=0;i < cmt;++i)
{
input[i]-=7;
}
cout << input << endl;
}
}
2008年10月12日 星期日
簡單的建立會員機制-建立新會員
Oracle Providers for ASP.NET 成員
OracleMembershipProvider
1.在Web.config加入以下內容
<?xml version="1.0"?>
<configuration xmlns=
"http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="my_membership_app_con_string" connectionString=
"User Id=scott;Password=tiger;Data Source=Oracle"/>
</connectionStrings>
<system.web>
<!-- Enable and customize OracleMembershipProvider settings -->
<membership defaultProvider="MyOracleMembershipProvider">
<providers>
<add name="MyOracleMembershipProvider"
type="Oracle.Web.Security.OracleMembershipProvider,
Oracle.Web, Version=2.111.6.20, Culture=neutral,
PublicKeyToken=89b483f429c47342"
connectionStringName="my_membership_app_con_string"
applicationName="my_membership_app"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="true"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="4"
minRequiredPasswordLength="9"
passwordAttemptWindow="8"/>
</providers>
</membership>
</system.web>
</configuration>
2.從工具箱拖曳元件CreateUserWizard。並設定MembershipProvider屬性。
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
MembershipProvider="MyOracleMembershipProvider">
<WizardSteps>
<asp:CreateUserWizardStep runat="server" />
<asp:CompleteWizardStep runat="server" />
</WizardSteps>
</asp:CreateUserWizard>
Using OracleSessionStateProvider Web.config
Oracle Providers for ASP.NET 成員之一。
讓asp.net網站在做NLB的架構時將SessionState存放在Oracle裡。
NLB成員,只要有一台Server能提供服務。
網站都能繼續提供服務使用者的操作完全不會中斷 。
<?xml version="1.0"?>
<configuration xmlns=
"http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="my_sessionstate_app_con_string" connectionString=
"User Id=scott;Password=tiger;Data Source=Oracle"/>
</connectionStrings>
<system.web>
<!-- Enable and customize OracleSessionStateProvider -->
<sessionState mode="Custom" customProvider="MyOracleSessionStateStore">
<providers>
<add name="MyOracleSessionStateStore"
type="Oracle.Web.SessionState.OracleSessionStateStore,
Oracle.Web, Version=2.111.6.20, Culture=neutral,
PublicKeyToken=89b483f429c47342"
connectionStringName="my_sessionstate_app_con_string"/>
</providers>
</sessionState>
</system.web>
</configuration>