摘要:
bool isPowerOfFour(int num){ return num > 0 && (num & (num - 1))== 0 && (num & 0xaaaaaaaa) == 0; } 阅读全文
摘要:
bool isPowerOfThree(int n){ // for (int i=0; pow(3,i)<=n; i++) // { // if (pow(3,i) == n) return true; // } // return false; return n > 0 && 116226146 阅读全文
摘要:
bool isPowerOfTwo(int n){ for (int i=0; i<31 && pow(2,i)<=n; i++) { if (pow(2,i) == n) return true; } return false; } bool isPowerOfTwo(int n){ return 阅读全文
摘要:
int cmp(const void* a, const void* b) { return *(int*)a - *(int*)b; } int* powerfulIntegers(int x, int y, int bound, int* returnSize){ if (bound<2) { 阅读全文
摘要:
bool isprime(int count) { if (count ==1) return false; for (int j=2; j<=sqrt(count); j++) { if(count % j == 0) return false; } return true; } int numP 阅读全文
摘要:
bool isprime(int count) { if (count ==1) return false; for (int j=2; j<=sqrt(count); j++) if(count % j == 0) return false; return true; } int countPri 阅读全文
摘要:
#include <semaphore.h> class Foo { protected: sem_t firstJobDone; sem_t secondJobDone; public: Foo() { sem_init(&firstJobDone, 0, 0); sem_init(&second 阅读全文
摘要:
char * reverseOnlyLetters(char * S){ int len = strlen(S); int left=0,right=len-1; char ch; while(left<right) { if (isalpha(S[left]) && isalpha(S[right 阅读全文
摘要:
struct ListNode* reverseList(struct ListNode* head){ if(!head || !head->next) return head; struct ListNode *res = reverseList(head->next); head->next- 阅读全文