本文整理汇总了C++中com函数的典型用法代码示例。如果您正苦于以下问题:C++ com函数的具体用法?C++ com怎么用?C++ com使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了com函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
char s[11];
long n;
int i,j;
while(scanf("%s",s)!=EOF)
{
for(i=0;s[i+1];i++)
{
if(s[i]>=s[i+1]) break;
}
if(s[i+1]) printf("0\n");
else
{
i=strlen(s);
for(--i,n=0;i;i--)
n+=com(26,i);
for(i=0;s[i];i++)
{
if(i==0)j='a';
else j=s[i-1]+1;
for(;j<s[i];j++)
{
n+=com('z'-j,strlen(s)-i-1);
}
}
printf("%ld\n",n+1);
}
}
return 0;
}
开发者ID:deeks-codestar,项目名称:Algorithm,代码行数:31,代码来源:POJ_1496_2262369_AC_0MS_24K.cpp
示例2: sizeof
void dgBody::ApplyImpulsesAtPoint (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const impulseArray, const dgFloat32* const pointArray)
{
dgInt32 stride = strideInBytes / sizeof (dgFloat32);
dgMatrix inertia (CalculateInertiaMatrix());
dgVector impulse (m_veloc.Scale3 (m_mass.m_w));
dgVector angularImpulse (inertia.RotateVector (m_omega));
dgVector com (m_globalCentreOfMass);
for (dgInt32 i = 0; i < count; i ++) {
dgInt32 index = i * stride;
dgVector r (pointArray[index], pointArray[index + 1], pointArray[index + 2], dgFloat32 (0.0f));
dgVector L (impulseArray[index], impulseArray[index + 1], impulseArray[index + 2], dgFloat32 (0.0f));
dgVector Q ((r - com) * L);
impulse += L;
angularImpulse += Q;
}
dgMatrix invInertia (CalculateInvInertiaMatrix());
m_veloc = impulse.Scale3(m_invMass.m_w);
m_omega = invInertia.RotateVector(angularImpulse);
m_sleeping = false;
m_equilibrium = false;
Unfreeze ();
}
开发者ID:Hurleyworks,项目名称:NewtonBlock,代码行数:28,代码来源:dgBody.cpp
示例3: div
void div(int a[],int b[],int ans[])
{
int i,j,k;
int vvv[28][35]={0};
int chengji[35]={0};
int aans[35]={0};
for(i=1;i<28;i++) vvv[i][i]=1;
for(i=1;i<28;i++)
{
for(;;)
{
add(aans,vvv[i],aans);
for(j=0;j<30;j++) chengji[j]=0;
mul(aans,b,chengji);
// cout<<i<<" aans: ";coutt(aans);cout<<endl;
// cout<<"chengji: ";coutt(chengji);cout<<endl;
if(!com(a,chengji))
{
for(k=0;k<30;k++) ans[k]=aans[k];
}
else
{
sub(aans,vvv[i],aans);
break;
}
}
}
}
开发者ID:ligy118,项目名称:wednesday_ljs,代码行数:31,代码来源:gaojingdu.cpp
示例4: main
int main()
{
int j,t,sc[11],i,k,co,cho,temp;
int ans;
scanf("%d",&t);
while(t--)
{
for(i=0;i<11;i++)
scanf("%d",&sc[i]);
for(i=1;i<11;i++)
{
temp=sc[i];
j=i-1;
while((temp<sc[j])&&(j>=0))
{
sc[j+1]=sc[j];
j=j-1;
}
sc[j+1]=temp;
}
scanf("%d",&k);
co=0;
for(i=0;i<11;i++)
if(sc[i]==sc[11-k])
co++;
i=11-k;
cho=0;
while(i<11&&sc[i]==sc[11-k])
{cho++;i++;}
printf("%ld\n",com(co,cho));
}
return 0;
}
开发者ID:CrazyCompiler,项目名称:BugFreeCodes,代码行数:33,代码来源:Top+Batsman.c
示例5: com
void KVINDRAOnlineDataAnalyser::HandleCommands(TString& ordre, TSocket* theSocket)
{
// Gestion des ordres
// Returns kTRUE if command was understood & executed
// Returns kFALSE if command unknown
//
// STOP will stop the analysis (calls EndRun() and EndAnalysis())
// CLEAR RAZ de tous les spectres
//
// DUMP=yes start dumping fired data parameters
// DUMP=no stop dumping fired data parameters
//
// SAVE=toto.root will save all histograms in '${ANALYSIS_RESULTS}/toto.root' (does not stop analysis)
// SAVE=/home/toto.root will save all histograms in '/home/toto.root' (does not stop analysis)
// SAVE will save all histograms in '${ANALYSIS_RESULTS}/[class name]_Run[run number]_[date].root' (does not stop analysis)
KVString com(ordre.Data());
com.Begin("=");
ordre = com.Next();
ordre.ToUpper();
if (ordre == "STOP") {
// arrete l'analyse, en appelant EndRun() et EndAnalysis()
fGoEventLoop = kFALSE;
theSocket->Send("ok");
return;
} else if (ordre == "SAVE") {
TString tmp_fil = com.Next();
TString fil;
bool send_name = kFALSE;
if (tmp_fil.Contains("/")) fil = tmp_fil;
else if (tmp_fil == "") {
TDatime save_time;
save_time.Set();
TString date = save_time.AsString();
date.ReplaceAll(" ", "_");
fil = Form("${ANALYSIS_RESULTS}/%s_Run%d_%s.root", GetName(), GetRunNumber(), date.Data());
send_name = kTRUE;
} else fil = Form("${ANALYSIS_RESULTS}/%s", tmp_fil.Data());
SaveSpectra(fil.Data());
if (send_name) theSocket->Send(fil.Data());
else theSocket->Send("ok");
return;
} else if (ordre == "CLEAR") {
ClearAllHistos();
theSocket->Send("ok");
return;
} else if (ordre == "DUMP") {
TString tmp_fil = com.Next();
tmp_fil.ToLower();
if (tmp_fil == "yes")fDumpEvents = kTRUE;
else if (tmp_fil == "no")fDumpEvents = kFALSE;
else {
theSocket->Send("unknown command");
return;
}
theSocket->Send("ok");
return;
}
theSocket->Send("unknown command");
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:60,代码来源:KVINDRAOnlineDataAnalyser.cpp
示例6: com
int com(int n, int r)
{
if(r==0 || r==1)
return n;
return ((n-r+1)*com(n,r-1)/r);
}
开发者ID:CrazyCompiler,项目名称:BugFreeCodes,代码行数:7,代码来源:Top+Batsman.c
示例7: init
/*
* prepares the communication maps for remote elements
* should be called immediately after load balancing,
* before any work transfer.
*
*/
void
NonlocalMaterialWTP :: init(Domain *domain)
{
int ie, gie, nelem = domain->giveNumberOfElements();
EngngModel *emodel = domain->giveEngngModel();
Element *elem;
int nproc = emodel->giveNumberOfProcesses();
int myrank = emodel->giveRank();
CommunicatorBuff cb(nproc, CBT_dynamic);
Communicator com(emodel, &cb, myrank, nproc, CommMode_Dynamic);
this->nonlocElementDependencyMap.clear();
// build nonlocal element dependency array for each element
for ( ie = 1; ie <= nelem; ie++ ) {
elem = domain->giveElement(ie);
if ( ( elem->giveParallelMode() == Element_local ) ) {
gie = elem->giveGlobalNumber();
this->giveElementNonlocalDepArry(nonlocElementDependencyMap [ gie ], domain, ie);
}
}
/* send and receive nonlocElementDependencyArry of migrating elements to remote partition */
com.packAllData(this, domain, & NonlocalMaterialWTP :: packMigratingElementDependencies);
com.initExchange(MIGRATE_NONLOCALDEP_TAG);
com.unpackAllData(this, domain, & NonlocalMaterialWTP :: unpackMigratingElementDependencies);
com.finishExchange();
}
开发者ID:vivianyw,项目名称:oofem,代码行数:33,代码来源:nonlocalmatwtp.C
示例8: RenderCenterOfMass
void RenderCenterOfMass (NewtonWorld* const world)
{
glDisable (GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glColor3f(0.0f, 0.0f, 1.0f);
glBegin(GL_LINES);
for (NewtonBody* body = NewtonWorldGetFirstBody(world); body; body = NewtonWorldGetNextBody(world, body)) {
dMatrix matrix;
dVector com(0.0f);
NewtonBodyGetCentreOfMass (body, &com[0]);
NewtonBodyGetMatrix (body, &matrix[0][0]);
dVector o (matrix.TransformVector (com));
dVector x (o + matrix.RotateVector (dVector (1.0f, 0.0f, 0.0f, 0.0f)));
glColor3f (1.0f, 0.0f, 0.0f);
glVertex3f (o.m_x, o.m_y, o.m_z);
glVertex3f (x.m_x, x.m_y, x.m_z);
dVector y (o + matrix.RotateVector (dVector (0.0f, 1.0f, 0.0f, 0.0f)));
glColor3f (0.0f, 1.0f, 0.0f);
glVertex3f (o.m_x, o.m_y, o.m_z);
glVertex3f (y.m_x, y.m_y, y.m_z);
dVector z (o + matrix.RotateVector (dVector (0.0f, 0.0f, 1.0f, 0.0f)));
glColor3f (0.0f, 0.0f, 1.0f);
glVertex3f (o.m_x, o.m_y, o.m_z);
glVertex3f (z.m_x, z.m_y, z.m_z);
}
glEnd();
}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:35,代码来源:DebugDisplay.cpp
示例9: momentofinertiamatrix
void momentofinertiamatrix(int type, double *MofImatrix)
{
int i,j,count;
double p1[3],massi;
std::vector<double> com (3);
count=0;
updatePartCfg(WITHOUT_BONDS);
for(i=0;i<9;i++) MofImatrix[i]=0.;
com = centerofmass(type);
for (j=0; j<n_part; j++) {
if (type == partCfg[j].p.type) {
count ++;
for (i=0; i<3; i++) {
p1[i] = partCfg[j].r.p[i] - com[i];
}
massi= (partCfg[j]).p.mass;
MofImatrix[0] += massi * (p1[1] * p1[1] + p1[2] * p1[2]) ;
MofImatrix[4] += massi * (p1[0] * p1[0] + p1[2] * p1[2]);
MofImatrix[8] += massi * (p1[0] * p1[0] + p1[1] * p1[1]);
MofImatrix[1] -= massi * (p1[0] * p1[1]);
MofImatrix[2] -= massi * (p1[0] * p1[2]);
MofImatrix[5] -= massi * (p1[1] * p1[2]);
}
}
/* use symmetry */
MofImatrix[3] = MofImatrix[1];
MofImatrix[6] = MofImatrix[2];
MofImatrix[7] = MofImatrix[5];
return;
}
开发者ID:Smiljanic,项目名称:espresso,代码行数:30,代码来源:statistics.cpp
示例10: sub
void sub(int a[],int b[],int ans[])
{
int jinwei=0;
int i,j,k;
if(com(a,b))
{
ans[35]=1;
sub(b,a,ans);
return ;
}
for(i=29;i>=0;i--)
{
ans[i]=jinwei+a[i];
if(ans[i]<b[i])
{
ans[i]+=10;
ans[i]-=b[i];
jinwei=-1;
}
else
{
ans[i]-=b[i];
jinwei=0;
}
}
}
开发者ID:ligy118,项目名称:wednesday_ljs,代码行数:26,代码来源:gaojingdu_jiajian.c
示例11: main
int main(){
char buf[1024];
while(scanf("%s",buf) != EOF){
printf("%d\n",com(buf));
}
return 0;
}
开发者ID:ProgrammerBill,项目名称:Algorithm,代码行数:8,代码来源:FourOperation.c
示例12: com
const arma::vec& CylindricalBirefringentMaterial::centerOfMass()
{
com.set_size(3);
com.fill(0.0);
double mass = 0.0;
for ( unsigned int z=0;z<Nz();z++ )
for ( unsigned int y=0;y<Ny();y++ )
for ( unsigned int x=0;x<Nx();x++ )
{
com(0) += x*get(x,y,z);
com(1) += y*get(x,y,z);
com(2) += z*get(x,y,z);
mass += get(x,y,z);
}
com /= mass;
return com;
}
开发者ID:davidkleiven,项目名称:OptiX,代码行数:17,代码来源:cylindricalBirefringentMaterial.cpp
示例13: assert
Vector3d Skeleton::getWorldCOM() {
assert(mMass != 0);
Vector3d com(0, 0, 0);
const int nNodes = getNumNodes();
for(int i = 0; i < nNodes; i++) {
BodyNode* node = getNode(i);
com += (node->getMass() * node->getWorldCOM());
}
return com / mMass;
}
开发者ID:Tarrasch,项目名称:dart,代码行数:10,代码来源:Skeleton.cpp
示例14: combine
vector<vector<int> > combine(int n, int k) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
vector<vector<int> > ret;
if(n < k || n <= 0 || k <= 0)
return ret;
vector<int> com(k);
combine(n, k, 0, com, ret);
return ret;
}
开发者ID:bluefishi,项目名称:sun_codeshop,代码行数:10,代码来源:combine.cpp
示例15: loop
void loop()
{
float result;
int key=resist();
if(key==15)
{
//LCM CLEAR
wlcmd_4('c',0x01);
_delay(1600);
//student num
student_num();
//parameter reset
aa=0;bb=0;_status0=0;
lcm_num[0]=0;
lcm_num[1]=0;
lcm_num[2]=0;
lcm_num[3]=0;
lcm_num[4]=0;
lcm_num[5]=0;
lcm_num[6]=0;
return;
}
if((key>=0)&&(key<=9)&&(_status0!=4))
{
wlcmd_4('d',key);
if(_status0==0)
{
aa=aa*10+key;
}
if(_status0==2)
{
bb=bb*10+key;
}
return;
}
if((key>=10)&&(key<=13)&&(_status0!=4))
{
if(_status0==0)
{
wlcmd_4('d',key);
operand=key;
_status0=2;
return;
}
}
if((key==14)&&(_status0!=4))
{
wlcmd_4('d',key);
result=com(aa,bb,operand);
divide(result);
_status0=4;
return;
}
return;
}
开发者ID:93i7xo2,项目名称:HT66F50-Homework103-1,代码行数:55,代码来源:計算機_FLOAT.C
示例16: tetrahedra
tetrahedra (point p1, point p2, point p3, point p4, bool v = false) : p {p1, p2, p3, p4}
{
label = p1.l;
totalPoints = 0;
wrongPoints = 0;
// create triangles
triangle t1(p1, p2, p3);
triangle t2(p2, p1, p4);
triangle t3(p3, p2, p4);
triangle t4(p1, p3, p4);
t1.getPlaneEquationCoefficients(a1, b1,c1,d1);
t2.getPlaneEquationCoefficients(a2, b2,c2,d2);
t3.getPlaneEquationCoefficients(a3, b3,c3,d3);
t4.getPlaneEquationCoefficients(a4, b4,c4,d4);
calculateSideLength();
if(v)
{
std::ofstream fpoints("points.dat");
fpoints << p1.x << " " << p1.y << " " << p1.z << std::endl;
fpoints << p2.x << " " << p2.y << " " << p2.z << std::endl;
fpoints << p3.x << " " << p3.y << " " << p3.z << std::endl;
fpoints << p4.x << " " << p4.y << " " << p4.z << std::endl;
fpoints.close();
}
centerX = (p1.x + p2.x + p3.x + p4.x)/4.0;
centerY = (p1.y + p2.y + p3.y + p4.y)/4.0;
centerZ = (p1.z + p2.z + p3.z + p4.z)/4.0;
if(v)
{
std::ofstream fnormals("normals.dat");
fnormals << centerX << " " << centerY << " " << centerZ << std::endl;
fnormals << centerX - a1 << " " << centerY - b1 << " " << centerZ - c1 << " " << d1 << std::endl << std::endl<< std::endl;
fnormals << centerX << " " << centerY << " " << centerZ << std::endl;
fnormals << centerX - a2 << " " << centerY - b2 << " " << centerZ - c2 << " " << d2 << std::endl << std::endl<< std::endl;
fnormals << centerX << " " << centerY << " " << centerZ << std::endl;
fnormals << centerX - a3 << " " << centerY - b3 << " " << centerZ - c3 << " " << d3 << std::endl << std::endl<< std::endl;
fnormals << centerX << " " << centerY << " " << centerZ << std::endl;
fnormals << centerX - a4 << " " << centerY - b4 << " " << centerZ - c4 << " " << d4 << std::endl << std::endl<< std::endl;
fnormals.close();
}
point com(centerX, centerY, centerZ +1 , 1);
if (!checkPointInside(com)) std::cerr << "ERROR: Center of Mass not inside Tetrahedra!" << std::endl;
}
开发者ID:spatialfruitsalad,项目名称:pomelo,代码行数:55,代码来源:tetrahedra.hpp
示例17: com
// -----------------------------------------------------------------------------
// Get the current COM location of the suspension subsystem.
// -----------------------------------------------------------------------------
ChVector<> ChDoubleWishboneReduced::GetCOMPos() const {
ChVector<> com(0, 0, 0);
com += getSpindleMass() * m_spindle[LEFT]->GetPos();
com += getSpindleMass() * m_spindle[RIGHT]->GetPos();
com += getUprightMass() * m_upright[LEFT]->GetPos();
com += getUprightMass() * m_upright[RIGHT]->GetPos();
return com / GetMass();
}
开发者ID:projectchrono,项目名称:chrono,代码行数:14,代码来源:ChDoubleWishboneReduced.cpp
示例18: main
//@ Main Function
int main() {
fac[0] = 1;
rep(i, 1, maxn) fac[i] = fac[i - 1] * i % mod;
inv[maxn - 1] = csl::inv(fac[maxn - 1], (ll)mod);
per(i, 1, maxn) inv[i - 1] = inv[i] * i % mod;
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int _, __ = 1;
for(; cin >> n >> s; --_, ++__) {
//std::cout << "Case #" << __ <<": ";
int l = n >> 1, r = n >> 1;
ll ans = 0;
if(n & 1) ans = 0;
else if(!valid(s, l, r)) ans = 0;
else if(!l) ans = 1;
else ans = (com(l + r, l) - com(l + r, l - 1) + mod) % mod;
cout << ans << endl;
}
return 0;
}
开发者ID:15310320305,项目名称:CodeWorld,代码行数:22,代码来源:hdu5184.cpp
示例19: com
b2Vec2 composite_body::get_com_position() const
{
b2Vec2 com(0.0f, 0.0f);
float sum_mass = 0.0f;
for(b2Body const* b : m_bodies)
{
float mass = b->GetMass();
com += mass * b->GetPosition();
sum_mass += mass;
}
return (1.0f / sum_mass) * com;
}
开发者ID:kamrann,项目名称:workbase,代码行数:12,代码来源:composite_body.cpp
示例20: main
int main(){
cmnLogger::SetMask( CMN_LOG_ALLOW_ALL );
cmnLogger::SetMaskFunction( CMN_LOG_ALLOW_ALL );
cmnLogger::SetMaskDefaultLog( CMN_LOG_ALLOW_ALL );
// Create the world
osaODEWorld* world = new osaODEWorld( 0.001 );
// Create a camera
int x = 0, y = 0;
int width = 640, height = 480;
double Znear = 0.01, Zfar = 10.0;
osg::ref_ptr<osaOSGMono> camera;
camera = new osaOSGMono( world,
x, y, width, height,
55, ((double)width)/((double)height),
Znear, Zfar );
camera->Initialize();
// Create objects
cmnPath path;
path.AddRelativeToCisstShare("/models");
path.AddRelativeToCisstShare("/models/hubble");
// Create a rigid body. Make up some mass + com + moit
double mass = 1.0;
vctFixedSizeVector<double,3> com( 0.0 );
vctFixedSizeMatrix<double,3,3> moit = vctFixedSizeMatrix<double,3,3>::Eye();
vctFixedSizeVector<double,3> u( 0.780004, 0.620257, 0.082920 );
u.NormalizedSelf();
vctFrame4x4<double> Rtwh( vctAxisAngleRotation3<double>( u, 0.7391 ),
vctFixedSizeVector<double,3>( 0.0, 0.0, 1.0 ) );
osg::ref_ptr<osaODEBody> hubble;
hubble = new osaODEBody( path.Find("hst.3ds"), world, Rtwh, mass, com, moit );
// Create a static body. This body has no mass and cannot be moved
osg::ref_ptr<osaODEBody> background;
background = new osaODEBody( path.Find("background.3ds"), world, vctFrm3() );
std::cout << "ESC to quit" << std::endl;
while( !camera->done() ){
world->Step();
camera->frame();
}
return 0;
}
开发者ID:jhu-saw,项目名称:sawOpenDynamicsEngine,代码行数:53,代码来源:osaODEBodyExample.cpp
注:本文中的com函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论