int similarTriangles(){ double a, b, c; printf("a = "); scanf("%lf", &a); printf("b = "); scanf("%lf", &b); printf("c = "); scanf("%lf", &c); if ((a > 0) && (b > 0) && (c > 0) && (a + b > c) && (a + c > b) && (b + c > a)){ printf("Треугольник 1 существует\n"); } else { printf("Треугольника 1 не существует\n"); return -1; } double a1, b1, c1; printf("a1 = "); scanf("%lf", &a1); printf("b1 = "); scanf("%lf", &b1); printf("c1 = "); scanf("%lf", &c1); if ((a1 > 0) && (b1 > 0) && (c1 > 0) && (a1 + b1 > c1) && (a1 + c1 > b1) && (b1 + c1 > a1)){ printf("Треугольник 2 существует\n"); } else { printf("Треугольника 2 не существует\n"); return -1; } double max1 = maxOfThree(a, b, c); double max2 = maxOfThree(a1, b1, c1); double koeff = max1/max2; double min1 = minOfThree(a, b, c); double min2 = minOfThree(a1, b1, c1); int isOk = 1; if (min1 / min2 != koeff){ printf("треугольники не подобные\n"); isOk = 0; return -1; } double avg1 = AvgOfThree(a, b, c); double avg2 = AvgOfThree(a1, b1, c1); if (avg1 / avg2 != koeff){ printf("треугольники не подобные\n"); isOk = 0; return -1; } if (isOk = !0){ printf("треугольники подобные\n"); } return 0; }
static void shareTheSystemLoad(bool shouldNotify) { static uint64_t lastSystemLoad = 0; uint64_t theseSystemLoad = 0; int userLevel = kIOSystemLoadAdvisoryLevelGreat; int batteryLevel = kIOSystemLoadAdvisoryLevelGreat; int powerLevel = kIOSystemLoadAdvisoryLevelGreat; int combinedLevel = kIOSystemLoadAdvisoryLevelGreat; /****************************************** * Power Level Computation code begins here * Edit this block of code to change what * defines a "good time" to do work, based on system load. */ /******************************************/ if (onACPower) { batteryLevel = kIOSystemLoadAdvisoryLevelGreat; } else if (!batteryBelowThreshold) { batteryLevel = kIOSystemLoadAdvisoryLevelOK; } else { batteryLevel = kIOSystemLoadAdvisoryLevelBad; } if (plimitBelowThreshold) { powerLevel = kIOSystemLoadAdvisoryLevelOK; } if (coresConstrained || forcedIdle || thermalWarningLevel) { powerLevel = kIOSystemLoadAdvisoryLevelBad; } // TODO: Use seconds since last UI activity as an indicator of // userLevel. Basing this data on display dimming is a crutch, // and may be invalid on systems with display dimming disabled. if (loggedInUser) { if (userIsIdle) { if (_DWBT_enabled()) { // System allows DWBT & user has opted in if (isA_BTMtnceWake( ) ) userLevel = kIOSystemLoadAdvisoryLevelGreat; else userLevel = kIOSystemLoadAdvisoryLevelOK; } else userLevel = kIOSystemLoadAdvisoryLevelGreat; } else { userLevel = kIOSystemLoadAdvisoryLevelOK; } // TODO: If user is performing a full screen activity, or // is actively producing UI events, time is BAD. } // The combined level is the lowest/worst level of the contributing factors combinedLevel = minOfThree(userLevel, batteryLevel, powerLevel); /******************************************/ /* Power Level Computation code ends here */ /******************************************/ theseSystemLoad = combinedLevel | (userLevel << 8) | (batteryLevel << 16) | (powerLevel << 24); if (theseSystemLoad != lastSystemLoad) { CFMutableDictionaryRef publishDetails = NULL; CFNumberRef publishNum = NULL; lastSystemLoad = theseSystemLoad; /* Publish the combinedLevel under our notify key 'kIOSystemLoadAdvisoryNotifyName' */ notify_set_state(gNotifyToken, (uint64_t)combinedLevel); /* Publish the SystemLoad key read by API * IOGetSystemLoadAdvisory(); */ publishNum = CFNumberCreate(0, kCFNumberSInt64Type, &theseSystemLoad); if (publishNum) { PMStoreSetValue(systemLoadKey, publishNum); CFRelease(publishNum); publishNum = NULL; } /* Publish the Detailed key read by API * CFDictionaryRef IOPMCheckSystemLoadDetailed(); */ publishDetails = CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); if (!publishDetails) return; publishNum = CFNumberCreate(0, kCFNumberIntType, &userLevel); if (publishNum) { CFDictionarySetValue(publishDetails, kIOSystemLoadAdvisoryUserLevelKey, publishNum); CFRelease(publishNum); publishNum = 0; } publishNum = CFNumberCreate(0, kCFNumberIntType, &batteryLevel); if (publishNum) { CFDictionarySetValue(publishDetails, kIOSystemLoadAdvisoryBatteryLevelKey, publishNum); CFRelease(publishNum); publishNum = 0; } publishNum = CFNumberCreate(0, kCFNumberIntType, &powerLevel); if (publishNum) { CFDictionarySetValue(publishDetails, kIOSystemLoadAdvisoryThermalLevelKey, publishNum); CFRelease(publishNum); publishNum = 0; } publishNum = CFNumberCreate(0, kCFNumberIntType, &combinedLevel); if (publishNum) { CFDictionarySetValue(publishDetails, kIOSystemLoadAdvisoryCombinedLevelKey, publishNum); CFRelease(publishNum); publishNum = 0; } // Publish SystemLoadDetailed PMStoreSetValue(systemLoadDetailedKey, publishDetails); CFRelease(publishDetails); // post notification if (shouldNotify) { notify_post(kIOSystemLoadAdvisoryNotifyName); } } }