• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Mod函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Mod函数的典型用法代码示例。如果您正苦于以下问题:C++ Mod函数的具体用法?C++ Mod怎么用?C++ Mod使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Mod函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Mod

void CFmBall::CheckGoalArea()
{
	if(abs(m_pPos->GetX()) > abs(INT_TO_FIXED(GOALPOST_X*BACK_X/1000)))
	{
		m_pPos->SetX(INT_TO_FIXED(GOALPOST_X*BACK_X/1000)*FmSign(m_pPos->GetX()));
		m_nAngle = Mod(360-m_nAngle, 360);
        
		m_nSpeedZ = m_nSpeedZ/6;
		m_nSpeed = m_nSpeed/6;
		//if(m_pPos->GetZ() < INT_TO_FIXED(20))
		//	m_pRefPlayMgr->m_pGoalPost[m_pPos->GetX()>0?1:0][2]->GetAniObject()->InitMotion(6, false);
		//else
		//	m_pRefPlayMgr->m_pGoalPost[m_pPos->GetX()>0?1:0][2]->GetAniObject()->InitMotion(5, false);
		//GET_APP()->PlaySound(SOUND_KIND_GOALWEB, false);
	}
    
	if (abs(m_pPos->GetY()) > abs(INT_TO_FIXED(GOALPOST_Y*BACK_Y/1000)))
	{
		m_pPos->SetY(INT_TO_FIXED(GOALPOST_Y*BACK_Y/1000)*FmSign(m_pPos->GetY()));
		m_nAngle = Mod(180-m_nAngle, 360);
		m_nSpeedZ = m_nSpeedZ / 6;
		m_nSpeed = m_nSpeed / 3;
		//if(m_pPos->GetY() > 0)
		//	m_pRefPlayMgr->m_pGoalPost[m_pPos->GetX()>0?1:0][0]->GetAniObject()->InitMotion(4, false);
	}
	if (m_pPos->GetZ() > INT_TO_FIXED(GOALPOST_Z))
	{
		m_pPos->SetZ(INT_TO_FIXED(GOALPOST_Z));
		m_nSpeedZ = m_nSpeedZ / 6;
		m_nSpeed = m_nSpeed / 6;
		if (m_nSpeedZ > 0)
            m_nSpeedZ *= -1;
		//m_pRefPlayMgr->m_pGoalPost[m_pPos->GetX()>0?1:0][0]->GetAniObject()->InitMotion(3, false);
	}
}
开发者ID:louis2001,项目名称:FMTeamTest,代码行数:35,代码来源:FmBall.cpp


示例2: dest

void Instance::InsertMod(size_t index, const wxFileName &source)
{
	wxFileName dest(Path::Combine(GetInstModsDir().GetFullPath(), source.GetFullName()));
	if (!source.SameAs(dest))
	{
		wxCopyFile(source.GetFullPath(), dest.GetFullPath());
	}

	dest.MakeRelativeTo();
	SetNeedsRebuild();
	
	int oldIndex = Find(modList.begin(), modList.end(), [&dest] (Mod mod) -> bool
		{ return mod.GetFileName().SameAs(dest); });
	
	if (oldIndex != -1)
	{
		modList.erase(modList.begin() + oldIndex);
	}
	
	if (index >= modList.size())
		modList.push_back(Mod(dest));
	else
		modList.insert(modList.begin() + index, Mod(dest));
	
	SaveModList();
}
开发者ID:bartbes,项目名称:MultiMC4,代码行数:26,代码来源:instance.cpp


示例3: readListFile

bool ModList::update()
{
	if (!isValid())
		return false;
	
	QList<Mod> newMods;
	m_dir.refresh();
	auto folderContents = m_dir.entryInfoList();
	bool orderWasInvalid = false;
	
	// first, process the ordered items (if any)
	int currentOrderIndex = 0;
	QStringList listOrder = readListFile();
	for(auto item: listOrder)
	{
		QFileInfo info (m_dir.filePath(item));
		int idx = folderContents.indexOf(info);
		// if the file from the index file exists
		if(idx != -1)
		{
			// remove from the actual folder contents list
			folderContents.takeAt(idx);
			// append the new mod
			newMods.append(Mod(info));
		}
		else
		{
			orderWasInvalid = true;
		}
	}
	for(auto entry: folderContents)
	{
		newMods.append(Mod(entry));
	}
	if(mods.size() != newMods.size())
	{
		orderWasInvalid = true;
	}
	else for(int i = 0; i < mods.size(); i++)
	{
		if(!mods[i].strongCompare(newMods[i]))
		{
			orderWasInvalid = true;
			break;
		}
	}
	beginResetModel();
	mods.swap(newMods);
	endResetModel();
	if(orderWasInvalid)
	{
		saveListFile();
		emit changed();
	}
	return true;
}
开发者ID:Apocalypsing,项目名称:MultiMC5,代码行数:56,代码来源:ModList.cpp


示例4: PowMod

/*
 * Must guarantee c+c DO NOT OVERFLOW!!!(both a, b, c are INTEGERS)
 * $a or $b may be negative, however $c must be positive
 */
template<class T> T PowMod( T a, T b, T c) {
   	T r=Mod((T)1,c);
   	a=Mod(a,c);
	while(b != 0) {
		if(b & 1) r=MulMod(r, a, c);
		a = MulMod( a, a, c);
		b >>= 1;
	}
	return r;
}
开发者ID:AekdyCoin,项目名称:Math,代码行数:14,代码来源:PowMod.cpp


示例5: multiply

void multiply(L F[2][2], L M[2][2])
{
  L x = F[0][0]*M[0][0] + F[0][1]*M[1][0];
  L y = F[0][0]*M[0][1] + F[0][1]*M[1][1];
  L z = F[1][0]*M[0][0] + F[1][1]*M[1][0];
  L w = F[1][0]*M[0][1] + F[1][1]*M[1][1];
  F[0][0] = Mod(x);
  F[0][1] = Mod(y);
  F[1][0] = Mod(z);
  F[1][1] = Mod(w);
}
开发者ID:sriankit,项目名称:cpp_codes,代码行数:11,代码来源:CSUMD_kholu.c


示例6: RoundDateToSpan

wxDateTime RoundDateToSpan(wxDateTime date, wxDateSpan span)
{
    wxDateTime::wxDateTime_t day = date.GetDay();
    int month = MonthNum(date.GetMonth());
    wxDateTime::wxDateTime_t year = date.GetYear();

    wxDateTime::wxDateTime_t modDays = Mod(day - 1, span.GetTotalDays());
    wxDateTime::wxDateTime_t modMonths = Mod(month - 1, span.GetMonths());
    wxDateTime::wxDateTime_t modYears = Mod(year, span.GetYears());

    return wxDateTime(day - modDays, MonthFromNum(month - modMonths), year - modYears);
}
开发者ID:lukecian,项目名称:wxfreechart,代码行数:12,代码来源:compdateaxis.cpp


示例7: Mod

/* function to calculate the potency (a^n % q) */
Mod Mod::pot(unsigned int n){
	if(n == 0){
		return Mod(1);
	}else{
		if(n == 1){
			return Mod(get_a());
		}
		if(n % 2 == 0){
			return pot(n/2) * pot(n/2);
		}
		if(n % 2 == 1){
			return pot(n-1) * Mod(get_a());
		}
	}
}
开发者ID:D4ryus,项目名称:studium,代码行数:16,代码来源:mod.cpp


示例8: test_parquetShader

//debug single parquetShader parts
extern "C" void test_parquetShader(DataStruct* data) 
{
  float m = data->f; //should be 1
  float l = m -10;
  float r = m +10;
  data->fa[0] = Mod(l,r);
  data->fa[1] = Mod(r,l);
  data->fa[2] = Mod(r,m);
  data->fa[3] = Step(l,r);
  data->fa[4] = Step(r,l);
  data->fa[5] = SmoothStep(l,r,m);
  data->fa[6] = SmoothStep(l,r,100*m);
  data->fa[7] = SmoothStep(l,r,-200*m);
  data->fa[8] = Mix(l,r,m);
}
开发者ID:jrk,项目名称:llvmptxbackend,代码行数:16,代码来源:PTXTestFunctions.cpp


示例9: assert

BigData BigData:: operator%(const BigData& bigdata)
{
	if (bigdata._strData[1] == '0')
	{
		cout << "除数为 0 或对0求模" << endl;
		assert(0);
	}
	if (_strData[1] == 0)
		return INT64(0);
	if ((IsINT64OverFlow()) && bigdata.IsINT64OverFlow())
	{
		return _value % bigdata._value;
	}
	if (_strData.size() < bigdata._strData.size())
	{
		return BigData(_strData.c_str());
	}
	else if (_strData.size() == bigdata._strData.size())
	{
		if (strcmp(_strData.c_str() + 1, bigdata._strData.c_str() + 1) < 0)
			return INT64(0);
		if (strcmp(_strData.c_str() + 1, bigdata._strData.c_str() + 1) == 0)
		{
			return INT64(0);
		}
	}
	return BigData(Mod(_strData, bigdata._strData).c_str());
}
开发者ID:needless-saying,项目名称:Big_Data_Operation,代码行数:28,代码来源:BigData.cpp


示例10: main

/*------------------------------------------------*/
int main(int argc,char **argv)
{
    int i,j,k;
    int length,width,tailleCarre;
    float** MatriceImgR;
    float** MatriceImgI;
    float** MatriceImgM;

    // Generation d'une image carre blanc sur fond noir
    length = 128;
    width = 128;

    printf("Veuillez entrer la taille du carre: ");
    scanf("%d", &tailleCarre);

    MatriceImgR = squareImage(length, width, tailleCarre);

    // Sauvegarde de MatriceImgR sous forme d'image pgm
    SaveImagePgm(NAME_IMG_OUT,MatriceImgR,length,width);

    // Allocation memoire pour la FFT
    MatriceImgI=fmatrix_allocate_2d(length,width);
    MatriceImgM=fmatrix_allocate_2d(length,width);

    // Initialisation a zero de toutes les matrices
    for(i=0;i<length;i++) 
    {
        for(j=0;j<width;j++) 
        {
	        MatriceImgI[i][j]=0.0;
	        MatriceImgM[i][j]=0.0;
        }
    }

    // Decalage de l'image pour obtenir un spectre au centre
    shiftSpatial(MatriceImgR,length,width);
  
    // FFT
    FFTDD(MatriceImgR,MatriceImgI,length,width);

    // Module
    Mod(MatriceImgM,MatriceImgR,MatriceImgI,length,width);

    // Pour visu
    //RecalLog(MatriceImgM,length,width);
    Recal(MatriceImgM,length,width);
    Mult(MatriceImgM,20,length,width);
  
    // Sauvegarde de MatriceImgM sous forme d'image pgm
    SaveImagePgm(NAME_SPC_OUT,MatriceImgM,length,width);

    // Liberation memoire pour les matrices
    free_fmatrix_2d(MatriceImgR);
    free_fmatrix_2d(MatriceImgI); 
    free_fmatrix_2d(MatriceImgM);

    // Retour sans probleme
    printf("\n C'est fini ... \n\n\n");
    return 0; 	 
}
开发者ID:smdarry,项目名称:tiaut2010,代码行数:61,代码来源:TpIFT6150-1-Ae.c


示例11: main

int main()
{
    // printf("hello, world");

    char result[BUFFER_SIZE];
    char remainder[BUFFER_SIZE];

    // please make sure the bit length is enough before calculate
    // especially when you do a large power operation
    // you can change it by define: BIG_INT_BIT_LEN
    // the default bit length for BigInt is 1024

    // routine test
    puts(Add("2010", "4", result));
    puts(Sub("0", "2014", result));
    puts(Mul("2", "43", result));
    puts(Div("86", "10", result, remainder));
    puts(remainder);
    puts(Mod("-86", "10", result));
    puts(PowMod("7", "80", "86", result));

    // BigInt test
    puts(Sub("233333333333333333333333333333333333333333333333", "33", result));
    puts(Mul("2333333333333333333333333333333", "2333333333333333333", result));
    puts(Div("2333333333333333333333333333333", "2333333333333333332", result, remainder));
    puts(remainder);
    puts(Pow("8", "86", result));

    return 0;
}
开发者ID:xkuga,项目名称:bigint,代码行数:30,代码来源:bigint_en.c


示例12: inputStream

void Instance::LoadModList()
{
	if (GetModListFile().FileExists())
	{
		wxFileInputStream inputStream(GetModListFile().GetFullPath());
		wxStringList modListFile = ReadAllLines(inputStream);
		
		for (wxStringList::iterator iter = modListFile.begin(); iter != modListFile.end(); iter++)
		{
			// Normalize the path to the instMods dir.
			wxFileName modFile(*iter);
			modFile.Normalize(wxPATH_NORM_ALL, GetInstModsDir().GetFullPath());
			modFile.MakeRelativeTo();
			
			if (!Any(modList.begin(), modList.end(), [&modFile] (Mod mod) -> bool
				{ return mod.GetFileName().SameAs(wxFileName(modFile)); }))
			{
				//SetNeedsRebuild();
				modList.push_back(Mod(modFile));
			}
		}
	}
	
	for (size_t i = 0; i < modList.size(); i++)
	{
		if (!modList[i].GetFileName().FileExists())
		{
			SetNeedsRebuild();
			modList.erase(modList.begin() + i);
			i--;
		}
	}
	
	LoadModListFromDir(GetInstModsDir());
}
开发者ID:bartbes,项目名称:MultiMC4,代码行数:35,代码来源:instance.cpp


示例13: SetWhichSeesMouse

void aui_Tab::MouseLGrabInside( aui_MouseEvent *mouseData )
{
	if ( IsDisabled() ) return;
	if ( !GetWhichSeesMouse() || GetWhichSeesMouse() == this )
	{
		SetWhichSeesMouse( this );

		PlaySound( AUI_SOUNDBASE_SOUND_EXECUTE );

		
		HideTipWindow();

		
		SetMouseOwnership();
		ReleaseMouseOwnership();
		SetKeyboardFocus();

		m_mouseCode = AUI_ERRCODE_HANDLEDEXCLUSIVE;

		
		if ( !HandleGameSpecificLeftClick( this ) )
		if ( 0 < m_state && m_state < m_numStates - 1 )
			SetState( Mod(m_state+1,m_numStates) );
		else
			SetState( 1 );

		m_attributes |= k_CONTROL_ATTRIBUTE_ACTIVE;

		
		m_draw |= m_drawMask & k_AUI_REGION_DRAWFLAG_MOUSELGRABINSIDE;
	}
	else
		MouseLGrabOutside( mouseData );
}
开发者ID:talentlesshack,项目名称:C2P2,代码行数:34,代码来源:aui_tab.cpp


示例14: main

int main() {
	int B, P, M;
	while(scanf("%d %d %d", &B, &P, &M) == 3) {
		printf("%lld\n", Mod(B, P, M));
	}
    return 0;
}
开发者ID:JohnXinhua,项目名称:UVa,代码行数:7,代码来源:374+-+Big+Mod.cpp


示例15: main

void main(){
	int a,b,t;
	printf("enter the a and b value:\n");
	scanf("%d %d",&a,&b);
	Mod(a,b);
	printf("t=%d",t);
}
开发者ID:lixiangbest,项目名称:algorithm,代码行数:7,代码来源:9.2.c


示例16: Negate

 void Negate()
 {
     T nim = -1 / Mod();
     x *= nim;
     y *= nim;
     z *= nim;
     w *= -nim;
 }
开发者ID:gitter-badger,项目名称:luddite,代码行数:8,代码来源:quaternion.hpp


示例17: ex_gcd

	void ex_gcd(int a, int b, int &x, int& y) {
		if (!b) {
			x = 1, y = 0;
			return;
		}
		ex_gcd(b, Mod(a, b), x, y);
		int t = x; x = y, y = t - a / b * y;
	}
开发者ID:AiHaibara,项目名称:acm-icpc,代码行数:8,代码来源:1407.cpp


示例18: CheckGoalpost

bool CFmBall::Update(bool bTmp/* = false*/)
{
    bool ret = false;
    //좌표이동
    *m_pPos = *m_pPos + FmP3D(-sin(CC_DEGREES_TO_RADIANS(m_nAngle))*m_nSpeed, cos(CC_DEGREES_TO_RADIANS(m_nAngle))*m_nSpeed, m_nSpeedZ);
    
    if(!bTmp)
        ret = CheckGoalpost();
    
    if(m_pPos->GetZ() <= 0)                     //땅에 닿았을때 처리
    {
        if(m_nSpeedZ == 0)
        {
            if(m_nSpeed/20 > CON_SPEED_REG2)
                m_nSpeed -= m_nSpeed/20;        //공 빠르면 많이 차감
            else
                m_nSpeed -= CON_SPEED_REG2;     //공기 저항 속도
        }
        else
        {
            m_nSpeed = m_nSpeed * CON_SPEED_REG/1000 - CON_SPEED_REG2;
        }
        
        m_nSpeedZ = -m_nSpeedZ * CON_SPEEDZ_REG/1000 - CON_SPEEDZ_REG2;         //Z축 속도 감소
        if(m_nSpeedZ < INT_TO_FIXED(1))
            m_nSpeedZ = 0;
        
        m_pPos->SetZ(0);
        m_nAngle = m_nAngle + m_nSpin/16;
        m_nSpin = m_nSpin * CON_SPIN_REG/1000;
        
        if(!bTmp)
        {
            if(m_nSpeedZ != 0)
                SetBoundPos();
            else
                m_nBoundHH = -1;
        }
    }
    else
    {
        m_nSpeed = m_nSpeed * CON_SPEED_AIR_REG/1000;
        m_nSpeedZ -= CON_SPEEDZ_AIR_REG;
        int t = 10 + m_nSpeed / INT_TO_FIXED(30);
        m_nAngle = m_nAngle + m_nSpin*t/900;
        m_nSpin = m_nSpin * CON_SPIN_AIR_REG/1000;
    }
    
    m_nAngle = Mod(m_nAngle, 360);
    if(m_nSpeed < INT_TO_FIXED(1))
        m_nSpeed = 0;
    if(m_nNotForceFlag > 0)
        m_nNotForceFlag--;
    if(m_nMissFlag > 0)
        m_nMissFlag--;
    
    return ret;
}
开发者ID:louis2001,项目名称:FMTeamTest,代码行数:58,代码来源:FmBall.cpp


示例19: Gao

	inline int Gao(int a, int b, int c) {
		int t = gcd(abs(a), abs(b)); if (a < 0 || b < 0) t = -t;
		if (Mod(c, t) != 0) return 1521521521;
		int x = 0, y = 0;
		a /= t, b /= t, c /= t;
		ex_gcd(a, b, x, y);
		x *= c;
		while (x < 0) x += b; while (x > b) x -= b;
		return x;
	}
开发者ID:AiHaibara,项目名称:acm-icpc,代码行数:10,代码来源:1407.cpp


示例20: Mod

bool FrameLimiter::ShouldUpdate(float frametime)
{
    t += frametime;
    if (t >= step)
    {
        t = Mod(t, step);
        return true;
    }
    return false;
}
开发者ID:aoighost,项目名称:tundra-urho3d,代码行数:10,代码来源:CoreTimeUtils.cpp



注:本文中的Mod函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Mode函数代码示例发布时间:2022-05-30
下一篇:
C++ Mmsg函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap