void main() { cnt=sum=0; countValue(); printf("满足条件的整数的个数=%d\n",cnt); printf("满足条件的整数的和值=%d\n",sum); }
void main() { cnt=sum=0; countValue(); printf("满足条件的个数=%d\n",cnt); printf("满足条件所有的SIX与NINE的和=%d\n",sum); }
bool report(Census &census, MutableHandleValue report) { RootedObject obj(census.cx, NewBuiltinClassInstance(census.cx, &JSObject::class_)); RootedValue countValue(census.cx, NumberValue(counter)); if (!obj || !JSObject::defineProperty(census.cx, obj, census.cx->names().count, countValue)) { return false; } report.setObject(*obj); return true; }
void RenderVideoFrame::setState(int v) { if (v != state && -2 <= v && v <= 3) { state = v; switch (state) { case -2: // uninitialized point_x = point_y = -1; value = 0; capturing = false; update(); break; case -1: // initialized point_x = point_y = -1; // do it again in case of restarting value = 0; startCapturing(0); setState(0); break; case 0: // waiting for user to select the object to track break; case 1: // tracking object and selecting circles break; case 2: // finished everything :) stopCapturing(); countValue(); initCircles(); update(); break; case 3: // interrupted :( stopCapturing(); initCircles(); update(); break; } emit stateChanged(v); } }
int main (void) { int i; int a[5] = {5,3,2,4,1}; int b[5] = {-1, 0, 0, 0, 1}; int c[5] = {-10, 9, -8 , 7, -6}; printf("max(a, 5) = %d\n", max(a, 5)); printf("countValue (a, 5, 1) = %d\n", countValue (a, 5, 1)); printf("countValue (a, 5, 0) = %d\n", countValue (a, 5, 0)); printf("isSorted (a, 5) = %d\n", isSorted (a, 5)); printf("isPermutation (a, 5) = %d\n", isPermutation (a, 5)); printf("max(b, 5) = %d\n", max(b, 5)); printf("countValue (b, 5, 1) = %d\n", countValue (b, 5, 1)); printf("countValue (b, 5, 0) = %d\n", countValue (b, 5, 0)); printf("isSorted (b, 5) = %d\n", isSorted (b, 5)); printf("isPermutation (b, 5) = %d\n", isPermutation (b, 5)); absolute (c, 5); for (i = 0; i < 5; i++) printf ("c[%d] = %d\n", i, c[i]); return 0; }
/** * It parses input table file and populated table with their repective values * It also performs sanity check for input values so that they conform to DES specification */ void ProcessTableCheck(FILE *tf) { char *key_ptr, *value_ptr; char buf[1024]; int i; while (fgets(buf, sizeof buf, tf) != NULL) { key_ptr = buf; value_ptr = strchr(buf, '='); // each line must exist in format key=value if (value_ptr == NULL) { fprintf(stderr, "input of table file must exist in key=value pair\n"); exit(1); } *value_ptr = '\0'; value_ptr++; if (value_ptr == NULL || strcmp(value_ptr, "") == 0) { fprintf(stderr, "Error : %s value can not be null or empty\n", key_ptr); exit(1); } if (value_ptr[strlen(value_ptr) - 1] == '\n') { value_ptr[strlen(value_ptr) - 1] = '\0'; } if (strcmp("S", key_ptr) == 0) { if (S != NULL) { Error("S"); } if (strlen(value_ptr) != 512) { fprintf(stderr, "Error : invalid S-box, wrong number of entries.\n"); exit(1); } S = initTable("S", value_ptr, 32, 32); int *count = (int *) malloc(sizeof(int) * 256); countValue(count, "S", S, 16, 16); for (i = 0; i < 256; i++) { if (count[i] != 1) { if (count[i] == 0) fprintf(stderr, "Error : {%02x} not found in S box\n", i); else fprintf(stderr, "Error : {%02x} found %d times in S box. It should occur only once\n", i, count[i]); exit(1); } } free(count); } else if (strcmp("P", key_ptr) == 0) { if (P != NULL) { Error("P"); } if (strlen(value_ptr) != 8) { fprintf(stderr, "Error : invalid P, wrong number of entries\n"); exit(1); } P = initTable("P", value_ptr, 2, 8); } else if (strcmp("INVP", key_ptr) == 0) { if (INVP != NULL) { Error("INVP"); } if (strlen(value_ptr) != 8) { fprintf(stderr, "Error : invalid INVP, wrong number of entries\n"); exit(1); } INVP = initTable("INVP", value_ptr, 2, 8); } else { fprintf(stderr, "Invalid input key %s in table file.\n", key_ptr); exit(1); } } if (!feof(tf)) { fprintf(stderr, "Error while reading input table file. Please try running this program after sometime.\n"); exit(1); } if (P == NULL) { fprintf(stderr, "Error : Missing P in table file\n"); exit(1); } if (S == NULL) { fprintf(stderr, "Error : Missing S in table file\n"); exit(1); } if (INVP == NULL) { fprintf(stderr, "Error : Missing INVP in table file\n"); exit(1); } unsigned char *prod = ModProduct(*P, *INVP); if (prod[0] != 0x00 || prod[1] != 0x00 || prod[2] != 0x00 || prod[3] != 0x01) { fprintf(stderr, "INVP is not multiplicative inverse of P\n"); exit(1); } populateINVSTable(); if (table_check == 1) { cleanUpAllTables(); } }