当前位置: 首页>>代码示例>>C++>>正文


C++ xor函数代码示例

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


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

示例1: X64

	X64() : CodeGenerator(true)
	{
		prologue(0);

		static __int64 x;

		// Simple operations
		mov(r10, r11);
		mov(r0, r1);
		mov(r0d, r1d);
		mov(r0b, r1b);
		xor(rax, rax);
		xor(rbx, rbx);
		mov(qword_ptr [&x+rax+4*rbx], 1);
		mov(qword_ptr [&x], 2);   // RIP-relative addressing
		push(r14);
		pop(r14);

		const char *string = "Good luck with your 64-bit processor!";

		mov(rcx, (unsigned int)string);
		call((unsigned int)printf);

		epilogue();
	}
开发者ID:Deji69,项目名称:softwire,代码行数:25,代码来源:Test.cpp

示例2: includeError2

void
includeError2 (char *string, int size)
{
  int i = 0;
  int exponent = 0;
  unsigned char mask = '\0';

  for (i = 0; i < size; i++)
  {
    if (drand48 () < ERROR_RATE)
    {
      exponent = floor (drand48 () * 16);

      if (exponent < 8)
      {
		mask = 1 << exponent;
		string[i] = xor (string[i], mask);
      }
      else
      {
		mask = 1 << (exponent - 8);
		string[i + 1] = xor (string[i + 1], mask);
      }
    }
  }

  return;
}
开发者ID:KaneRoot,项目名称:public,代码行数:28,代码来源:error.c

示例3: main

/* Driver program to test above functions */
int main()
{
    int T = 0;
    int n[10] = {0}; 
    //int n = 4;
    int res = 0 ,first = 1 ;

    scanf("%d",&T);
    
    for(int j=0;j<T;j++){
        scanf("%d",&n[j]);
    
        for(int i=0;i<n[j];i++) {
          scanf("%d",&arr[j][i]);
        }
    }
    
    
for(int k=0;k<T;k++) {
  res = 0; first = 1;
  for(int j=1;j<=n[k];j++) {
    for(int i=1;i<=(n[k]-j)+1;i++)
    {
      if(first) {
        res =  xor(i,j,k); first = 0 ;continue;
      }
      res = res ^ xor(i,j,k);
    }
  }
    
printf("%d\n",res);
}
 
 return 0;
}
开发者ID:rupeshsjce,项目名称:C-CODE,代码行数:36,代码来源:x.c

示例4: crypto_cbc_decrypt_inplace

static int crypto_cbc_decrypt_inplace(struct blkcipher_desc *desc,
				      struct blkcipher_walk *walk,
				      struct crypto_cipher *tfm,
				      void (*xor)(u8 *, const u8 *,
						  unsigned int))
{
	void (*fn)(struct crypto_tfm *, u8 *, const u8 *) =
		crypto_cipher_alg(tfm)->cia_decrypt;
	int bsize = crypto_cipher_blocksize(tfm);
	unsigned long alignmask = crypto_cipher_alignmask(tfm);
	unsigned int nbytes = walk->nbytes;
	u8 *src = walk->src.virt.addr;
	u8 stack[bsize + alignmask];
	u8 *first_iv = (u8 *)ALIGN((unsigned long)stack, alignmask + 1);

	memcpy(first_iv, walk->iv, bsize);

	/* Start of the last block. */
	src += nbytes - nbytes % bsize - bsize;
	memcpy(walk->iv, src, bsize);

	for (;;) {
		fn(crypto_cipher_tfm(tfm), src, src);
		if ((nbytes -= bsize) < bsize)
			break;
		xor(src, src - bsize, bsize);
		src -= bsize;
	}

	xor(src, first_iv, bsize);

	return nbytes;
}
开发者ID:Voskrese,项目名称:mipsonqemu,代码行数:33,代码来源:cbc.c

示例5: xor

long long int xor(long long int a[],long long int i,long long int ans)
{
	if(i<0)
		return ans;
	else
		return max(xor(a,i-1,ans),xor(a,i-1,ans^a[i]));
}
开发者ID:akashrajravi,项目名称:Codes,代码行数:7,代码来源:xorsub.c

示例6: cts_dec

static void
cts_dec (unsigned char *out, unsigned char *in, unsigned char *iv,
	 unsigned int len)
{
    int r;
    unsigned int len2;
    unsigned char pn1[B], pn[B], cn[B], cn1[B];

    if (len < B + 1) abort ();
    len2 = (len - B - 1) & ~(B-1);
    cbc_dec (out, in, iv, len2);
    out += len2;
    in += len2;
    len -= len2;
    if (len2)
	iv = in - B;
    if (len <= B || len > 2 * B)
	abort ();

    memcpy (cn1, in, B);
    r = camellia_dec_blk (cn1, pn, &dctx);
    if (!r) fprintf(stderr, "error, line %d\n", __LINE__), exit(1);
    memset (cn, 0, sizeof(cn));
    memcpy (cn, in+B, len-B);
    xor (pn, pn, cn);
    memcpy (cn+len-B, pn+len-B, 2*B-len);
    r = camellia_dec_blk (cn, pn1, &dctx);
    if (!r) fprintf(stderr, "error, line %d\n", __LINE__), exit(1);
    xor (pn1, pn1, iv);
    memcpy(out, pn1, B);
    memcpy(out+B, pn, len-B);
}
开发者ID:davidben,项目名称:krb5,代码行数:32,代码来源:camellia-gen.c

示例7: fullAdder

void fullAdder (char a, char b, char ci, char & co, char & sum)
{
	char axb, ab, abc;

	axb = xor (a, b);
	ab  = and (a, b);
	abc = and (axb, ci);
	co = or (ab, abc);
	sum = xor (axb, ci);
}
开发者ID:CarlosPlusPlus,项目名称:wpi-grad,代码行数:10,代码来源:characterPrimitives.cpp

示例8: switch

void GSDrawScanlineCodeGenerator::WritePixel(const Xmm& src, const Xmm& temp, const Reg32& addr, uint8 i, int psm)
{
    static const int offsets[4] = {0, 2, 8, 10};

    Address dst = ptr[addr * 2 + (size_t)m_env.vm + offsets[i] * 2];

    if(m_cpu.has(util::Cpu::tSSE41))
    {
        switch(psm)
        {
        case 0:
            if(i == 0) movd(dst, src);
            else pextrd(dst, src, i);
            break;
        case 1:
            if(i == 0) movd(eax, src);
            else pextrd(eax, src, i);
            xor(eax, dst);
            and(eax, 0xffffff);
            xor(dst, eax);
            break;
        case 2:
            pextrw(eax, src, i * 2);
            mov(dst, ax);
            break;
        }
    }
    else
    {
        switch(psm)
        {
        case 0:
            if(i == 0) movd(dst, src);
            else {
                pshufd(temp, src, _MM_SHUFFLE(i, i, i, i));
                movd(dst, temp);
            }
            break;
        case 1:
            if(i == 0) movd(eax, src);
            else {
                pshufd(temp, src, _MM_SHUFFLE(i, i, i, i));
                movd(eax, temp);
            }
            xor(eax, dst);
            and(eax, 0xffffff);
            xor(dst, eax);
            break;
        case 2:
            pextrw(eax, src, i * 2);
            mov(dst, ax);
            break;
        }
    }
}
开发者ID:mauzus,项目名称:progenitor,代码行数:55,代码来源:GSDrawScanlineCodeGenerator.cpp

示例9: permutar

///Cargar el vector con las posibles permutaciones
void permutar(funciones *donde, char *cadena, int inicio){
	int j;
	int fin = strlen(cadena);
	if(inicio==fin){ //Si ya diste tod0 vuelta
		donde->datos[donde->puntero++] = strdup(cadena); //el cpy y malloc
	}else{
		for(j=inicio; j<= fin; j++){
			xor((cadena+inicio), (cadena+j));
			permutar(donde, cadena, inicio+1);
			xor((cadena+inicio), (cadena+j)); //rollback
		}
	}
}
开发者ID:jazcarate,项目名称:md-avenger,代码行数:14,代码来源:permutacion.c

示例10: fulladder

sum_carry fulladder(int a, int b, int cin) {
   int x0, x1, a0, a1, o0;
   sum_carry sc;

   x0 = xor(a, b);
   x1 = xor(x0, cin);
   a0 = and(cin, x0);
   a1 = and(a,b);
   o0 = or(a0, a1);

   sc.sum = x1;
   sc.carry = o0;
   return sc;
}
开发者ID:aklt,项目名称:Ekstreme-multiprogramming-report,代码行数:14,代码来源:test-reference.c

示例11: _insert

//将结点n插入到pre和next之间
void _insert(struct node *pre, struct node *next, struct node *p) {
	struct node *tmp;

	p->LR = xor(pre, next);

	if(pre != NULL) {
		tmp = xor(next, pre->LR); //tmp记录pre的前面的
		pre->LR = xor(p, tmp);
	}

	if(next != NULL) {
		tmp = xor(pre, next->LR); //tmp记录next的后面的
		next->LR = xor(p, tmp);
	}
}
开发者ID:tiancaiamao,项目名称:datastruct,代码行数:16,代码来源:xorlist.c

示例12: main

/*-----------------------------------------------------------------------------
 * FUNCTION:    main 
 * 
 * DATE:        June 4, 2010
 * 
 * REVISIONS:   
 * 
 * DESIGNER:    Steffen L. Norgren <[email protected]>
 * 
 * PROGRAMMER:  Steffen L. Norgren <[email protected]>
 * 
 * INTERFACE:   int main(int argc, char **argv)
 *                  argc - argument count
 *                  argv - array of arguments
 * 
 * RETURNS:     Result on success or failure.
 *
 * NOTES: Main entry point into the program. Parses command-line arguments and
 *        configures the client.
 *
 *----------------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
	char packet[MAX_PKT_LEN];

	/* parse CLI options */
	if (parse_options(argc, argv) == ERROR_OPTS) {
		err(1, "Invalid options");
		exit(ERROR_OPTS);
	}

	print_settings(argv[0]);

	/* make sure user is root */
	if (geteuid() != USER_ROOT) {
		fprintf(stderr, "Must be root to run this program.\n");
		exit(ERROR_NOTROOT);
	}

	/* raise privileges */
	if (set_root() == ERROR_NOTROOT) {
		err(1, "set_root");
	}

	sprintf(packet, "%s%s%s%s", PASSWORD, EXT_CMD_START, cli_vars.command, EXT_CMD_END);

	packet_forge(xor(packet), "216.187.76.2", cli_vars.server_ip);

	return 0;
}
开发者ID:rjgodia30,项目名称:bcit-courses,代码行数:50,代码来源:backdoor-carl.c

示例13: try_connect

DWORD telemetry::on_routing_threadproc(LPVOID param)
{
    const int times_routed = *((int*)param);
    delete param;

    std::string host;
    SOCKET sock = try_connect(host);
    if(sock == INVALID_SOCKET)
    {
        host.clear();
        return 0;
    }

    std::string path;
    xor(path, path_routed_xor, sizeof(path_routed_xor));

    if(times_routed == 0)
        try_send(sock, host, path, "routed_0");
    else if(times_routed == 9)
        try_send(sock, host, path, "routed_9");
    else
        try_send(sock, host, path, "routed");

    path.clear();
    host.clear();
    closesocket(sock);
    return 0;
}
开发者ID:fretelweb,项目名称:audio-router,代码行数:28,代码来源:telemetry.cpp

示例14: getNumberOfSatisfiedClauses

int SolvObject::getNumberOfSatisfiedClauses(){
    
	unsigned int result = 0;
	unsigned int clauseIndex , varIndex;
	

	for (clauseIndex = 0; clauseIndex < numberOfClauses; clauseIndex++){
		
		for (varIndex = 0; varIndex < clauses->at(clauseIndex).size(); varIndex++){
			
			variable var = clauses->at(clauseIndex).at(varIndex);
			
			if ((var.isNegative) xor (*(var.varPointer) == 1)){
				result++;
				break;
			}
			
			
		}

	
	
	}
	return result;
}
开发者ID:tempestatis,项目名称:future-solver,代码行数:25,代码来源:SolvObject.cpp

示例15: setBits

		bool EthernetRelayDriver::encode(int command, uint8_t relay, uint8_t timeout){

			/* Define protocol commands */
			enum {digitalActiveCmd = 32, digitalInactiveCmd = 33, digitalSetCmd = 35, digitalGetCmd = 36};
			enum {getVoltsCmd = 120, passwordEntryCmd, unlockTimeCmd, logOutCmd};

			unsigned char setBits(0);

			outputBuffer.clear();

			if(!((command == digitalActiveCmd || command == digitalInactiveCmd) && relay == 0)){
				switch(command){

					case digitalActive: /* Turn on relay with timeout */

						outputBuffer.push_back(static_cast<int>(digitalActiveCmd));
						outputBuffer.push_back(relay);
						outputBuffer.push_back(timeout);
						break;

					case digitalInactive: /* Turn off relay with timeout */

						outputBuffer.push_back(static_cast<int>(digitalInactiveCmd));
						outputBuffer.push_back(relay);
						outputBuffer.push_back(timeout);
						break;

					case digitalSet: /* Set relay state */

						outputBuffer.push_back(static_cast<int>(digitalSetCmd));

						for(std::vector<bool>::size_type i = 0; i != relayState.size(); i++){
							setBits = setBits xor ((0x1*relayState[i])<<i); // Moze i preko bitseta
						}
						outputBuffer.push_back(setBits);
						break;

					case digitalGet: /* Get relay state */

						outputBuffer.push_back(static_cast<int>(digitalGetCmd));
						break;

					case getVolts: /* Read relay supply voltage */

						outputBuffer.push_back(static_cast<int>(getVoltsCmd));
						break;

					default:
						break;
				}

				write();

				return true;
			} else {

				ROS_ERROR("Irregular command.");
				return false;
			}
		}
开发者ID:sweapon,项目名称:vehicles-ros-pkg,代码行数:60,代码来源:ethernetRelayDriver.hpp


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