本文整理汇总了C++中checkSum函数的典型用法代码示例。如果您正苦于以下问题:C++ checkSum函数的具体用法?C++ checkSum怎么用?C++ checkSum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkSum函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: checkSum
void checkSum(TreeNode *root, int sum, vector<int> tmp) {
if(root == NULL)
return;
tmp.push_back(root->val);
if(sum == root->val && root->left == NULL && root->right == NULL) {
result.push_back(tmp);
return;
}
if(root->left != NULL) checkSum(root->left, sum - root->val, tmp);
if(root->right != NULL) checkSum(root->right, sum - root->val, tmp);
}
开发者ID:reckhhh,项目名称:LeetCodeSolutons,代码行数:11,代码来源:113_PathSumII_Medium.cpp
示例2: main
int main()
{
int x,y;
BSTNode *root=0;
Interval *interval=0;
size_t len;
char buf[4096];
FILE *fi = fopen("TestOutput.out", "rb");
FILE *fo=fopen("logs.txt","a");
len = fread(buf, sizeof(char), sizeof(buf), fi);
displayTime(fo);
fprintf(fo,"Before execution:\n");
fprintf(fo,"The checksum of %s is %#x\n","output.out", checkSum(buf, len, 0));
fi=fopen("TestInput.in","r+");
fo=fopen("TestOutput.out","w");
//generateInput(nodeNr,intervalNr,pointNr,fi);
fi=fopen("TestInput.in","r");
for(int i=1; i<=nodeNr; i++)
{
interval=createNewInterval(interval,fi);
root=insert(root,interval);
free(interval);
}
fprintf(fo,"\n");
for(int i=1; i<=intervalNr; i++) {
interval=createNewInterval(interval,fi);
fprintf(fo,"\n\nQuerry interval: [%d,%d] \n",interval->lo,interval->hi);
fprintf(fo,"Intersected intervals:\n");
segmentIntersect(root,interval,fo);
free(interval);
}
for(int i=1; i<=pointNr; i++) {
fprintf(fo,"\n");
fscanf(fi,"%d",&x);
fprintf(fo,"\n\nQuerry point:%d \n",x);
searchPoint(root,x,fo);
fprintf(fo,"\n");
}
fi = fopen("TestOutput.out", "rb");
fo=fopen("logs.txt","a");
len = fread(buf, sizeof(char), sizeof(buf), fi);
fprintf(fo,"After execution:\n");
fprintf(fo,"The checksum of %s is %#x\n\n","output.out", checkSum(buf, len, 0));
return 0;
}
开发者ID:Naginn,项目名称:ADS,代码行数:51,代码来源:TestMain.cpp
示例3: readFlash
void bq34z100::chg48Table(uint16_t designCap, uint16_t designEnergy, uint16_t CellVT1T2, uint16_t CellVT2T3, uint16_t CellVT3T4, uint16_t CellVT4T5)
{
readFlash(48, 24);
chgFlashPair(21, designCap);
chgFlashPair(23, designEnergy);
chgFlashPair(28, CellVT1T2);//0x0E10 = 3600
chgFlashPair(30, CellVT2T3);//0x0E10 = 3600
checkSum(48, 24);
delay(300);
readFlash(48, 35);
chgFlashPair(32, CellVT3T4);//0x0E10 = 3600
chgFlashPair(34, CellVT4T5);//0x0E10 = 3600
checkSum(48, 35);
}
开发者ID:Ralim,项目名称:BQ34Z100,代码行数:14,代码来源:bq34z100.cpp
示例4: cmdHelp
void cmdHelp(void) // Lists Available Commands
{
char outstr[10];
int k;
for(k=0;k<cmdNumber;k++) // iterate through all
{
myStringPut( cmdSet[k].cmdName ); // output command name
outstr[0]=checkSumDigit1(checkSum(cmdSet[k].cmdName));
outstr[1]=checkSumDigit0(checkSum(cmdSet[k].cmdName));
outstr[2]='\0';
myStringPut(outstr);
myNLPut();
}
}
开发者ID:rheostat2718,项目名称:a,代码行数:14,代码来源:commandinterpreter.c
示例5: delay
*/ uint8_t WaspRFID::read(uint8_t address, uint8_t *readData) //!Reading
{
delay(2);
digitalWrite(MUX_USB_XBEE, HIGH);
delay(2);
printString(" ", _uart);
dataTX[0] = 0x05;
lengthCheckSum(dataTX); // Length Checksum
dataTX[2] = HOSTTOPN532; // Code
dataTX[3] = INDATAEXCHANGE; // Code
dataTX[4] = 0x01; // Number of targets
dataTX[5] = MIFARE_READ; //ReadCode
dataTX[6] = address; //Read address
dataTX[7] = 0x00;
checkSum(dataTX);
sendTX(dataTX , 8, 30);
memset(readData, 0x00, 16);
if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
for (int i = 12; i < 28; i++) {
readData[i-12] = dataRX[i];
}
return 0;
} else {
return 1;
}
}
开发者ID:ferrangb,项目名称:waspmoteapi,代码行数:29,代码来源:WaspRFID13.cpp
示例6: run
void run() {
createAccumulator();
accumulator()->process(Value(numeric_limits<long long>::max()), false);
accumulator()->process(Value(numeric_limits<long long>::max()), false);
accumulator()->process(Value(1.0), false);
checkSum();
}
开发者ID:Andiry,项目名称:mongo,代码行数:7,代码来源:accumulatortests.cpp
示例7: main
int main(int argc, char* argv[]) {
FILE *fp;
FILE *newfile;
size_t len;
char *buf;
long fsize;
int cs;
char ch;
if (argc != 2) {
printf("Usage: %s <filename>\n", argv[0]);
exit(-1);
}
/* Open the specified file */
fp = fopen(argv[1], "r");
if (fp == NULL) {
printf("Unable to open %s\n", argv[1]);
exit(-1);
}
/*Open the file that is to be copied to */
newfile = fopen("copyfile", "w+");
if (newfile == NULL) {
printf("Unable to create file");
exit(-1);
}
/* Obtain the file size */
fseek(fp, 0, SEEK_END);
fsize = ftell(fp);
rewind(fp);
/* Copy file to buf */
buf = (char*) malloc(sizeof(char)*fsize);
/*read and write the files in 1kb blocks*/
while (! feof (fp)) {
printf("reading block\n");
len += fread(buf, 1, 1024, fp);
printf("writing block\n");
fwrite (buf, 1, len, newfile);
printf("1kb read and written\n");
}
if (len != fsize) {
printf("Error reading file %s", argv[1]);
exit(-1);
}
cs = checkSum(buf, len, 0);
printf("%d bytes were read in total\n", len);
printf("Checksum of %s is %d\n", argv[1], cs);
fclose(newfile);
fclose(fp);
free(buf);
}
开发者ID:iczyg,项目名称:cmps111,代码行数:60,代码来源:checksum.c
示例8: findWord
/*
void findWord(string);
findWOrd will search the hashtable and tell you if the word is found in it. if it is
found it prints out the index and the words found with it.
Pre-
Hashtable exists
Post-
prints out if word is found or not
*/
void Program::findWord(std::string word)
{
int h = checkSum(word);
bool found = false;
for(int i = 0; i < hashTable[h].words.size(); i++)
{
if(hashTable[h].words[i] == word)
{
found = true;
break;
}
}
if(found)
{
std::cout<<"found at hash value: "<<h<<std::endl;
std::cout<<"along with: ";
for(int i = 0; i < hashTable[h].words.size(); i++)
{
if(hashTable[h].words[i] != word)
{
std::cout<<hashTable[h].words[i]<<"; ";
}
}
std::cout<<std::endl;
}
else
{
std::cout<<"word not found"<<std::endl;
}
}
开发者ID:joshuajenkins109,项目名称:Jenkins_Moser_CSCI_Final_Project,代码行数:39,代码来源:Program.cpp
示例9: addWord
void Program::addWord(std::string word)
{
if(wordExist(word) == false)
{
hashTable[checkSum(word)].words.push_back(word);
}
}
开发者ID:joshuajenkins109,项目名称:Jenkins_Moser_CSCI_Final_Project,代码行数:7,代码来源:Program.cpp
示例10: init
//**********************************************************************
//!The goal of this command is to detect as many targets (maximum MaxTg)
// as possible in passive mode.
uint8_t init(uint8_t *UID , uint8_t *ATQ) //! Request InListPassive
{
Serial.flush();
dataTX[0] = 0x04; // Length
lengthCheckSum(dataTX); // Length Checksum
dataTX[2] = 0xD4;
dataTX[3] = 0x4A; // Code
dataTX[4] = 0x01; //MaxTarget
dataTX[5] = 0x00; //BaudRate = 106Kbps
dataTX[6] = 0x00; // Clear checkSum position
checkSum(dataTX);
sendTX(dataTX , 7 ,23);
for (int i = 17; i < (21) ; i++){
_UID[i-17] = dataRX[i];
UID[i-17] = _UID[i-17];
}
ATQ[0] = dataRX[13];
ATQ[1] = dataRX[14];
if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x4B) & (dataRX[11] == 0x01)) {
return 0;
} else {
return 1;
}
}
开发者ID:rayui,项目名称:electricfoosball,代码行数:32,代码来源:example.cpp
示例11: laserReadline
uint64_t
hokuyo::Laser::readTime(int timeout)
{
char buf[100];
laserReadline(buf, 100, timeout);
if (!checkSum(buf, 6))
HOKUYO_EXCEPT(hokuyo::CorruptedDataException, "Checksum failed on time stamp.");
unsigned int laser_time = ((buf[0]-0x30) << 18) | ((buf[1]-0x30) << 12) | ((buf[2]-0x30) << 6) | (buf[3] - 0x30);
if (laser_time == last_time_)
{
if (++time_repeat_count_ > 2)
{
HOKUYO_EXCEPT(hokuyo::RepeatedTimeException, "The timestamp has not changed for %d reads", time_repeat_count_);
}
else if (time_repeat_count_ > 0)
ROS_DEBUG("The timestamp has not changed for %d reads. Ignoring for now.", time_repeat_count_);
}
else
{
time_repeat_count_ = 0;
}
if (laser_time < last_time_)
wrapped_++;
last_time_ = laser_time;
return (uint64_t)((wrapped_ << 24) | laser_time)*(uint64_t)(1000000);
}
开发者ID:AutoPark,项目名称:Hokuyo_Drivers,代码行数:32,代码来源:hokuyo.cpp
示例12: writeData
//**********************************************************************
//!Write 16 bytes in address .
uint8_t writeData(uint8_t address, uint8_t *blockData) //!Writing
{
Serial.print(" ");
dataTX[0] = 0x15;
lengthCheckSum(dataTX); // Length Checksum
dataTX[2] = 0xD4;
dataTX[3] = 0x40;//inDataEchange CODE
dataTX[4] = 0x01;//Number of targets
dataTX[5] = 0xA0;//Write Command
dataTX[6] = address; //Address
for (int i = 0; i < 16; i++) {
dataTX[i+7] = blockData[i];
}
dataTX[23] = 0x00;
checkSum(dataTX);
sendTX(dataTX , 24 ,14);
if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
return 0;
} else {
return 1;
}
}
开发者ID:rayui,项目名称:electricfoosball,代码行数:27,代码来源:example.cpp
示例13: HOKUYO_EXCEPT
int
hokuyo::Laser::sendCmd(const char* cmd, int timeout)
{
if (!portOpen())
HOKUYO_EXCEPT(hokuyo::Exception, "Port not open.");
char buf[100];
//printf("sendreq: %s\n", cmd);
laserWrite(cmd);
laserWrite("\n");;
laserReadlineAfter(buf, 100, cmd, timeout);
laserReadline(buf,100,timeout);
//printf("chksum: %s",buf);
if (!checkSum(buf,4))
{
//printf("chksum error\n");
HOKUYO_EXCEPT(hokuyo::CorruptedDataException, "Checksum failed on status code.");
}
buf[2] = 0;
//printf("sendreq_end: %s\n", cmd);
if (buf[0] - '0' >= 0 && buf[0] - '0' <= 9 && buf[1] - '0' >= 0 && buf[1] - '0' <= 9)
return (buf[0] - '0')*10 + (buf[1] - '0');
else
HOKUYO_EXCEPT(hokuyo::Exception, "Hokuyo error code returned. Cmd: %s -- Error: %s", cmd, buf);
}
开发者ID:bakdeniz,项目名称:jaguarControlISL,代码行数:26,代码来源:hokuyo.cpp
示例14: main
int main (void)
{
long long int realCardNumber;
int checkSum (long long int realCardNumber);
printf ("Type in the credit card number\n");
scanf ("%lli", &realCardNumber);
if ( checkSum(realCardNumber) == 0 )
{
printf ("Yup, it's good.");
}
else
printf ("Nope...\n%i", checkSum(realCardNumber));
return 0;
}
开发者ID:djeastm,项目名称:c-kochan-programming-in-c,代码行数:17,代码来源:Misc-CCValidator2.c
示例15: gpsLoop_
static void gpsLoop_(const char *msg, uint8_t) {
++gpsN;
if (!checkSum(msg)) {
++gpsKo;
return;
}
almalog("gps", msg);
}
开发者ID:chtronche,项目名称:Almabraxas2,代码行数:8,代码来源:gps.cpp
示例16: routeSum
vector<vector<TreeNode*>> routeSum(TreeNode* root, int num) {
if (root == nullptr) return vector<vector<TreeNode*>>();
vector<vector<TreeNode*>> result;
vector<TreeNode*> route;
checkSum(root, num, route, result);
return result;
}
开发者ID:mahaicheng,项目名称:cracking-the-coding-interview,代码行数:8,代码来源:4.9.cpp
示例17: cSum
virtual unsigned_32 cSum() const {
if ( _namePlusVar._strLen > 0 ) {
if ( *_namePlusVar._string > 0 ) {
return checkSum(_namePlusVar._string);
}
}
return NO_CHKSUM;
}
开发者ID:ArmstrongJ,项目名称:open-watcom-v2,代码行数:8,代码来源:cssymbol.hpp
示例18: readTime
void
hokuyo::Laser::readData(hokuyo::LaserScan& scan, bool has_intensity, int timeout)
{
scan.ranges.clear();
scan.intensities.clear();
int data_size = 3;
if (has_intensity)
data_size = 6;
char buf[100];
int ind = 0;
scan.self_time_stamp = readTime(timeout);
int bytes;
float range;
float intensity;
for (;;)
{
bytes = laserReadline(&buf[ind], 100 - ind, timeout);
if (bytes == 1) // This is \n\n so we should be done
return;
if (!checkSum(&buf[ind], bytes))
HOKUYO_EXCEPT(hokuyo::CorruptedDataException, "Checksum failed on data read.");
bytes += ind - 2;
// Read as many ranges as we can get
for (int j = 0; j < bytes - (bytes % data_size); j+=data_size)
{
if (scan.ranges.size() < MAX_READINGS)
{
range = (((buf[j]-0x30) << 12) | ((buf[j+1]-0x30) << 6) | (buf[j+2]-0x30)) / 1000.0;
scan.ranges.push_back(range);
if (has_intensity)
{
intensity = (((buf[j+3]-0x30) << 12) | ((buf[j+4]-0x30) << 6) | (buf[j+5]-0x30));
scan.intensities.push_back(intensity);
}
}
else
{
HOKUYO_EXCEPT(hokuyo::CorruptedDataException, "Got more readings than expected");
}
}
// Shuffle remaining bytes to front of buffer to get them on the next loop
ind = 0;
for (int j = bytes - (bytes % data_size); j < bytes ; j++)
buf[ind++] = buf[j];
}
}
开发者ID:AutoPark,项目名称:Hokuyo_Drivers,代码行数:58,代码来源:hokuyo.cpp
示例19: checkLazyWrite
static void ICACHE_FLASH_ATTR checkLazyWrite(void) {
if (dirtyCount == 0)
return;
if (!checkSum()) { // data has changed
saveSum();
CFG_Save();
TESTP("sysCfg updated\n");
}
}
开发者ID:Daven005,项目名称:ESP8266,代码行数:9,代码来源:config.c
示例20: CFG_checkLazyWrite
void ICACHE_FLASH_ATTR CFG_checkLazyWrite(void){
if (dirtyCount == 0) return;
if ((system_get_time() - lastSetDirty) > 2000000) {
if (!checkSum()) { // data has changed
saveSum();
CFG_Save();
TESTP("sysCfg updated\n")
}
lastSetDirty = system_get_time();
}
开发者ID:Daven005,项目名称:ESP8266,代码行数:10,代码来源:config.c
注:本文中的checkSum函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论