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

C++ printInt函数代码示例

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

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



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

示例1: updateDisplay

void updateDisplay() {
  int elapsed = 0;
  int countdown = 0;
  elapsed = s_currentTimer/2;
  countdown = s_selectedDuration - elapsed;
  
  if(s_currentTimer%2 == 0) {
    static char bUp[10];
    static char bDown[4];
    //static char bDuration[10];
    //static char bDuration[5];
    //static int elapsed = 0;
    //static int countdown = 0;
    
    //elapsed = s_currentTimer/2;
    //countdown = s_selectedDuration - elapsed;
    if(countdown > 0) {
      //printInt(s_countup, elapsed, bUp);
      printInt(s_countdown, countdown, bDown);
      //printInt(s_duration, s_selectedDuration, bDuration);
      
      snprintf(bUp, 10, "%d / %d", elapsed, s_selectedDuration);
      text_layer_set_text(s_countup, bUp);
    } else {
      printInt(s_countup, elapsed - s_selectedDuration, bUp);
      //text_layer_set_text(s_duration, "");
    }
    
     if(countdown == 10) {
      vibes_double_pulse();
    } else if(countdown == 3) {
      vibes_long_pulse();
    } else if(countdown == 2 || countdown == 1) {
      vibes_short_pulse();
    } else if(countdown == 0) {
      window_set_background_color(s_window, GColorWhite);
      vibes_long_pulse();
      s_timerActive = false;
      updateMenu(s_selectedDuration);
      text_layer_set_text(s_countdown, "");
      text_layer_set_text(s_countup, "");
      updateSets();
    }
  }
  
  if(s_timerActive) {
    if(countdown <= 10) {
       window_set_background_color(s_window, GColorRed);
    } else if (s_currentTimer < s_selectedDuration) {
      window_set_background_color(s_window, GColorGreen);
    } else {
      window_set_background_color(s_window, GColorOrange);
      if(s_currentTimer == s_selectedDuration) { // halfway point
        vibes_double_pulse();
      } 
    }
  }
}
开发者ID:eviltobz,项目名称:pebble_jim,代码行数:58,代码来源:timer.c


示例2: example_1

void example_1()
{
	int a = 111; // as we know a is a Lvalue.

	printInt(a); // so here, the printInt(int&) will be called.

	printInt(a + 2); // but here, the Rvalue version ( printInt(int&&) ) will be called.

}
开发者ID:dhustkoder,项目名称:code_backup,代码行数:9,代码来源:Move_Semantics.cpp


示例3: printOutput

/* printOutput takes the arrays of integers and argv and prints them to
 * 	stdout. It makes calls to printInt to accomplis this.
 * 
 * Parameters:
 *   int array[]: Array of hex values converted to integers
 *   char *copyofArgv[]: the stdin arguments passed to the program
 *   int numOfInts: size of array[]
 */
void printOutput(int array[], char *copyOfArgv[], int numOfInts) {
  int i;
  for ( i = 1; i < numOfInts; i++ ) {
    printf("%s\n", copyOfArgv[i]);
    printf("Decimal: ");
    printInt(array[i - 1], 10);
    printf("Binary: ");
    printInt(array[i - 1], 2);
  }
}
开发者ID:Sandesh-bn,项目名称:Homework,代码行数:18,代码来源:convert.c


示例4: vPrintDistance

// This task is used to print the instantaneous distances to the OLED display.
// Only want to print to the OLED display once autonomous/manual mode is initiated
void vPrintDistance(void *vParameters) {
  while(1) {
    if (state == 6 || state == 5 || state == 9) { // autonomous/manual mode states
      printInt(LookupDistanceTable(dist0), 70, 24);
      printInt(LookupDistanceTable(dist1), 70, 34);
      printInt(LookupDistanceTable(dist2), 70, 44);
      printInt(LookupDistanceTable(dist3), 70, 54);
    }
    vTaskDelay(50); // delay of about 20 ms
  }
}
开发者ID:eeshanl,项目名称:ee472,代码行数:13,代码来源:display.c


示例5: shake_detect_update

void shake_detect_update() {
	// if (shakeDetected == 0) SHAKE_DETECT_TIMER_COUNTER = 0;	// reset timer when no shake was detected

	const int32_t totalG = ACCEL_getTotalVectorSquared();

	if (shakeDetected == 1 && minShakeTimeExceeded == 0
	 && SHAKE_DETECT_TIMER_COUNTER >= minShakeTimeCounterVal)  // it was shaken long enough
	{	
		minShakeTimeExceeded = 1;
		// DIGIWRITE_H(PORTB, PB1);
	}

	if (shakeLevel > 0) {	// when a shake level is given, 
		shakeLevel--;	// calm down again
#ifdef DEBUG
		softuart_putchar('l');
		softuart_putchar('=');
		printInt(shakeLevel);PRINT_NL;
#endif
	}

	// check if we can end the shake event
	if (shakeLevel < SHAKE_DETECT_THRESH && shakeDetected != 0 && minShakeTimeExceeded != 0) {
#ifdef DEBUG
		softuart_putchar('s');PRINT_NL;
#endif
		shakeDetected = 0;
		// DIGIWRITE_L(PORTB, PB1);
		minShakeTimeExceeded = 0;
		(*shakeDetectEndCallback)();
	} else if (totalG > SHAKE_DETECT_SHOCK_THRESH
	        && shakeLevel + SHAKE_DETECT_SHOCK_LEVEL_INCREASE < SHAKE_DETECT_MAX_LEVEL)
	{
        shakeLevel += SHAKE_DETECT_SHOCK_LEVEL_INCREASE;	// get more excited

#ifdef DEBUG
		// printUInt(totalG);PRINT_NL;
		softuart_putchar('l');
		softuart_putchar('=');
		printInt(shakeLevel);PRINT_NL;
#endif

		// check if we can start the shake event
		if (shakeLevel >= SHAKE_DETECT_THRESH && shakeDetected == 0) {
#ifdef DEBUG
			softuart_putchar('S');PRINT_NL;
#endif
			shakeDetected = 1;
			SHAKE_DETECT_TIMER_COUNTER = 0;	// reset the timer
			(*shakeDetectBeginCallback)();
		}
	}
}
开发者ID:htw-inka,项目名称:attiny-soundcube,代码行数:53,代码来源:shake_detect.c


示例6: core0

// Core 0
// consume & check data
int core0()
{
	printStr("Benchmark mc_produce_consume\n");

	// start counting instructions and cycles
	int cycles, insts;
	cycles = getCycle();
	insts = getInsts();

    // check data found in the common fifo
    uint32_t data = 0;
    int new_head_index = 0;
    for(int i = 0; i < DATA_SIZE; i++) {
		new_head_index = *head_index;
        while( new_head_index == *tail_index ); // wait for data to be produced
        data = fifo_data[new_head_index];
        new_head_index++;
        if( new_head_index == FIFO_SIZE ) {
            new_head_index = 0;
        }
        *head_index = new_head_index;
        if( data != input_data[i] ) {
			printStr("At index "); printInt(i);
			printStr(", receive data = ");
			printInt(data);
			printStr(", but expected data = ");
			printInt(input_data[i]);
			printStr(", mismatch!\n");
			printStr("Return "); printInt(i+1); printChar('\n');
			return (i+1);
        }
    }

	// stop counting instructions and cycles
	cycles = getCycle() - cycles;
	insts = getInsts() - insts;

	// wait for core 1 to complete
	while(main1_done == 0);

	// print the cycles and inst count
	printStr("Cycles (core 0) = "); printInt(cycles); printChar('\n');
	printStr("Insts  (core 0) = "); printInt(insts); printChar('\n');
	printStr("Cycles (core 1) = "); printInt(main1_cycles); printChar('\n');
	printStr("Insts  (core 1) = "); printInt(main1_insts); printChar('\n');
	cycles = (cycles > main1_cycles) ? cycles : main1_cycles;
	insts = insts + main1_insts;
	printStr("Cycles  (total) = "); printInt(cycles); printChar('\n');
	printStr("Insts   (total) = "); printInt(insts); printChar('\n');

	printStr("Return 0\n");
	return 0;
}
开发者ID:geogunow,项目名称:Final_Project_6_175_Part2,代码行数:55,代码来源:mc_produce_consume_main.c


示例7: main

int main ( int argc, char *argv[] )
{
   List* list = list_create ( sizeof ( int ),EqualInt );
   int t;
   ListNode* n;
   int i;
   for ( i=0; i<10; ++i )
      list_push_back ( list,createInt ( &t,rand() ) );
   /*list_foreach(list,printInt);*/
   ListIter iter = list_get_iter ( list );
   while ( list_iter_hasNext ( iter ) )
   {
      printInt ( list_iter_next ( iter ) );
   }
   printf ( "\n" );
   list_pop_back ( list );
   list_foreach ( list,incInt );
   list_foreach ( list,printInt );
   printf ( "\n" );
   n = list_find_first_node ( list,createInt ( &t,846930887 ) );
   list_erase_node ( list,n );
   list_foreach ( list,printInt );
   list_delete ( list );
   return 0;
}
开发者ID:sunneo,项目名称:libs,代码行数:25,代码来源:main.c


示例8: warnCol

void warnCol(int i,int j,int k,int val) {
    int p,r;
    int square;
    int value;

    for(p=0; p<n; p++)
        if(p*n!=i)   //if it's not the allineation
        {
            square=p*n + j/n;   //position of this square in array q

            for(r=0; r<n; r++)
                if(m[p*n+r][j+k] & mask)
                {
                    if(DEBUG2) printf("subC: (%d,%d)=%d >>>>%d \n",p*n+r,j+k,m[p*n+r][j+k],m[p*n+r][j+k] & (m[p*n+r][j+k] ^ val));
                    m[p*n+r][j+k]=m[p*n+r][j+k] & (m[p*n+r][j+k] ^ val);

                    if(m[p*n+r][j+k]!=mask)
                    {
                        value=checkOneValue(p*n+r,j+k);
                        if(value>0)
                            setNum(p*n+r,j+k,value);
                    } else {
                        printInt("column error, value=",val);
                        //printf("column error: %d,%d+%d, =%d \n",i,j,k,val);
                    }
                }
        }
}
开发者ID:giovannipessiva,项目名称:sudoku-solver-2,代码行数:28,代码来源:chkSquare.c


示例9: printString

int printString(char* in)
{
	int size = (int)strlen(in);
	printInt(size+1);
	fwrite(in, sizeof(char), size+1, output);
	return 0;
}
开发者ID:Shima33,项目名称:gmftoolkit,代码行数:7,代码来源:byteFunctions.cpp


示例10: warnRow

void warnRow(int i,int j,int k,int val) {
    int p,r;
    int square;
    int value;

    for(p=0; p<n; p++)
        if(p*n!=j)   //if it's not the allineation
        {
            square=i + p;   //position of this square in array q

            for(r=0; r<n; r++)
                if(m[i+k][p*n+r] & mask)
                {
                    if(DEBUG2) printf("subR: (%d,%d)=%d >>>>%d \n",i+k,p*n+r,m[i+k][p*n+r],m[i+k][p*n+r] & (m[i+k][p*n+r] ^ val));
                    m[i+k][p*n+r]=m[i+k][p*n+r] & (m[i+k][p*n+r] ^ val);

                    if(m[i+k][p*n+r]!=mask)
                    {
                        value=checkOneValue(i+k,p*n+r);
                        if(value>0)
                            setNum(i+k,p*n+r,value);
                    } else {
                        printInt("row error, value=",val);
                        //printf("row error: %d+%d,%d, =%d \n",i,k,j,val);
                    }
                }
        }
}
开发者ID:giovannipessiva,项目名称:sudoku-solver-2,代码行数:28,代码来源:chkSquare.c


示例11: main

void main ( )
{
		int a,b,c,d,e,f,x;
		
		if ( x != 0 )
		{
			a = 4;
			c = 5 - d;
		}
		else
		{
			a = 6 + b;
			b = 3 - c;
		}

		if ( x < 2 )
		{
			b = 5 + c;
		}
		else
		{
			d = 6 + b;
		}

		f = a + 2;
		a = b + c;
		c = e + d;
		b = f + 1;
		e = a - 3;

		x = a + b + c + d + e + f;
		printInt(x);
}
开发者ID:bcarterterp,项目名称:Projects,代码行数:33,代码来源:test06.c


示例12: switch

// Render a value to text.
char*
aJsonClass::printValue(aJsonObject *item)
{
  char *out = NULL;
  if (!item)
    return NULL;
  switch (item->type)
    {
  case aJson_NULL:
    out = strdup("null");
    break;
  case aJson_False:
    out = strdup("false");
    break;
  case aJson_True:
    out = strdup("true");
    break;
  case aJson_Int:
    out = printInt(item);
    break;
  case aJson_Float:
    out = printFloat(item);
    break;
  case aJson_String:
    out = printString(item);
    break;
  case aJson_Array:
    out = printArray(item);
    break;
  case aJson_Object:
    out = printObject(item);
    break;
    }
  return out;
}
开发者ID:kkowar,项目名称:aJson,代码行数:36,代码来源:aJSON.cpp


示例13: printInt

void Environment::addDefaultFunctions() {
  // void printInt(int);
  FunType::PtrType printInt(new FunType("printInt"));
  printInt->args.push_back(AbsPtrType(new IntType()));
  printInt->ret_type = AbsPtrType(new VoidType());
  insertFunction(printInt);

  // void printString(string);
  FunType::PtrType printString(new FunType("printString"));
  printString->args.push_back(AbsPtrType(new StringType()));
  printString->ret_type = AbsPtrType(new VoidType());
  insertFunction(printString);

  // void error();
  FunType::PtrType error(new FunType("error"));
  error->ret_type = AbsPtrType(new VoidType());
  insertFunction(error);

  // int readInt();
  FunType::PtrType readInt(new FunType("readInt"));
  readInt->ret_type = AbsPtrType(new IntType());
  insertFunction(readInt);

  // string readString();
  FunType::PtrType readString(new FunType("readString"));
  readString->ret_type = AbsPtrType(new StringType());
  insertFunction(readString);
};
开发者ID:wojtekzozlak,项目名称:Studia.Archiwum,代码行数:28,代码来源:Environment.cpp


示例14: main

void main()
{
  int i, j=0, value=0, str_len, sum=0;
  int numbers[10];
  char buffer[100];
  
  printStr("enter seperated values: \n");
  readStr(buffer, 100);
  
  str_len=0;
  while (buffer[str_len] != 0)
    str_len++;
    
  for (i=0; i<str_len; i++)
  {
    if (buffer[i] == ',' || buffer[i] == ' ')
      continue; 
      
    if (!(buffer[i] >= '0' && buffer[i] <= '9'))
    {
      printStr("ERROR: numbers only allowed.\n");
      break;
    }
    
    while (buffer[i] >= '0' && buffer[i] <= '9')
    {
      int digit = buffer[i] - 48;
      value = value * 10 + digit;
      i++;
    }
    
    numbers[j] = value;
    value = 0;
    j++;
  }
  
  for (i=0; i<j; i++)
  {
    sum = sum + numbers[i];
    
    printInt(numbers[i]);
    printChar(' ');
  }
  
  printStr("\n\n Median(numbers) = ");
  printInt(sum / j);
}
开发者ID:malharthi,项目名称:scc,代码行数:47,代码来源:num-list.c


示例15: loadFile

/* 在文件系统中加载文件,文件大小写入size所指变量,返回bool值表示是否成功 */
bool loadFile(const char *path, uint32_t partitionFirstSector, uint32_t *size) {
    printString("    ");

    firstSector = partitionFirstSector;
    loadSector(firstSector + 2, superBlockBuffer);
    blockSize = (uint32_t) (1024 << superBlock->logBlockSize);
    sectorsPerBlock = blockSize / SECTOR_SIZE_512;

    if (superBlock->magic != EXT2_MAGIC_NUM) {
        printLine("incorrect ext2 magic number");
        return false;
    }
    if (superBlock->revLevel < EXT2_DYNAMIC_REV) {
        printLine("reversion of this ext2 filesystem is too old");
        return false;
    }
    if (blockSize > 0x10000) {
        printLine("block size is too large");
        return false;
    }

    uint32_t targetInode = EXT2_INODE_ROOT;

    for (const char *nameEnd = path; *nameEnd != '\0';) {
        for (path = nameEnd; *path == '/'; ++path);
        for (nameEnd = path; *nameEnd != '/' && *nameEnd != '\0'; ++nameEnd);
        if (nameEnd == path) {
            break;
        }
        targetInode = findChild(targetInode, path, nameEnd - path);
        if (targetInode == EXT2_INODE_NULL) {
            printLine("can't find such file");
            return false;
        }
    };

    Ext2Inode inode = loadInode(targetInode);
    if ((inode.mode & EXT2_MODE_FT_MASK) != EXT2_MODE_FT_REG_FILE) {
        printLine("not a regular file");
        return false;
    } else {
        printString("file found, size: ");
        printInt(inode.size);
        printString(" bytes (");
        printStorageSize(inode.size);
        printLine(")");
    }

    uint32_t blkCnt = inode.size / blockSize + (inode.size % blockSize != 0);
    for (uint32_t blockOffset = 0; blockOffset < blkCnt; ++blockOffset) {
        uint32_t block = getBlockIndex(&inode, blockOffset);
        if (!readFileSectorsToBuffer(lbaOfBlock(block), sectorsPerBlock)) {
            return false;
        }
    }

    *size = inode.size;
    return true;
}
开发者ID:GemBit,项目名称:PICOS,代码行数:60,代码来源:loader_ext2.c


示例16: main

int main()
{
	int n;
	printf("Enter an integer: ");
	scanf("%d", &n);//get the integer
	printInt(n); //function call to the library
	return 0;
}
开发者ID:nishkarsh-shastri,项目名称:Compilers_assignments_2014,代码行数:8,代码来源:print_int_call.c


示例17: main

int main(void) {
  char cr[2];

  cr[0]='\n';
  cr[1]=0;

  printString(cr);
  printInt(42);

  printString(cr);
  printInt(35+7);

  printString(cr);
  printInt(6*7);

  printString(cr);
  printInt(3*4+5*6);

  printString(cr);
  printInt(7*8-3*4-2);

  printString(cr);
  printInt((-6)*(-7));

  printString(cr);

  printInt( ((9 + 9 + 9) 
	     * ((9 + 9) / 9) 
	     * (9 * 9 - (9 + 9)) 
	     + (9 + 9)*(9+9+9)) 
	    / (9 * 9+9) 
	    - 9 / 9);

  printString(cr);
}
开发者ID:burbas,项目名称:MicroC,代码行数:35,代码来源:sim09.c


示例18: main0

int main0( )
{

  printStr("Benchmark mc_median\n");

  // start counting instructions and cycles
  int cycles, insts;
  cycles = getCycle();
  insts = getInsts();

  // do the median filter
  median_first_half( DATA_SIZE, input_data, results_data );

  // stop counting instructions and cycles
  cycles = getCycle() - cycles;
  insts = getInsts() - insts;

  // wait for main1 to finish
  while( main1_done == 0 );

  // print the cycles and inst count
  printStr("Cycles (core 0) = "); printInt(cycles); printChar('\n');
  printStr("Insts  (core 0) = "); printInt(insts); printChar('\n');
  printStr("Cycles (core 1) = "); printInt(main1_cycles); printChar('\n');
  printStr("Insts  (core 1) = "); printInt(main1_insts); printChar('\n');
  cycles = (cycles > main1_cycles) ? cycles : main1_cycles;
  insts = insts + main1_insts;
  printStr("Cycles  (total) = "); printInt(cycles); printChar('\n');
  printStr("Insts   (total) = "); printInt(insts); printChar('\n');

  // Check the results
  int ret = verify( DATA_SIZE, results_data, verify_data );
	printStr("Return "); printInt(ret); printChar('\n');
	return ret;
}
开发者ID:geogunow,项目名称:Final_Project_6_175_Part2,代码行数:35,代码来源:mc_median_main.c


示例19: incrTest

void incrTest() {
	int j = 0;
	int i[2];
	i[0] = 1;
	i[1] = 2;
	incr(&(j));
	incr(&(i[0]));
	incr(&(i[1]));
	
	printInt(j);
	printString("\n");
	
	printInt(i[0]);
	printString("\n");
	
	printInt(i[1]);
	printString("\n");
}
开发者ID:Databean,项目名称:mipsify,代码行数:18,代码来源:test.c


示例20: main

int main( int argc, char* argv[] )
{
  int results_data[DATA_SIZE];

  // Do the filter
  int cycles, insts;
  cycles = getTime();
  insts = getInsts();
  median( DATA_SIZE, input_data, results_data );
  cycles = getTime() - cycles;
  insts = getInsts() - insts;
  printStr("Cycles = "); printInt(cycles); printChar('\n');
  printStr("Insts  = "); printInt(insts); printChar('\n');

  // Check the results
  return !(verify( DATA_SIZE, results_data, verify_data ));

}
开发者ID:akashkrishnan,项目名称:6.175-lab5,代码行数:18,代码来源:median_main.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ printInteger函数代码示例发布时间:2022-05-30
下一篇:
C++ printInfo函数代码示例发布时间: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