本文整理汇总了C++中printInt函数的典型用法代码示例。如果您正苦于以下问题:C++ printInt函数的具体用法?C++ printInt怎么用?C++ printInt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printInt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
}
}
示例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.
}
示例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);
}
}
示例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
}
}
示例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)();
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例9: printString
int printString(char* in)
{
int size = (int)strlen(in);
printInt(size+1);
fwrite(in, sizeof(char), size+1, output);
return 0;
}
示例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);
}
}
}
}
示例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);
}
示例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;
}
示例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);
};
示例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);
}
示例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;
}