/** * Returns the state of the button * BUTTON_MONITOR_NOT_PRESSED 0 * BUTTON_MONITOR_DEPRESSED 1 * BUTTON_MONITOR_PRESSED 2 * BUTTON_MONITOR_REPEATING 3 * BUTTON_MONITOR_FAST_REPEATING 4 * BUTTON_MONITOR_RELEASED 5 */ uint8_t NIButtonMonitor::getState(uint8_t buttonId) { if (isDepressed(buttonId)) return BUTTON_MONITOR_DEPRESSED; if (isReleased(buttonId)) return BUTTON_MONITOR_RELEASED; if (isFastRepeating(buttonId)) return BUTTON_MONITOR_FAST_REPEATING; if (isRepeating(buttonId)) return BUTTON_MONITOR_REPEATING; if (isPressed(buttonId)) return BUTTON_MONITOR_PRESSED; return BUTTON_MONITOR_NOT_PRESSED; }
int main(){ char curWord[200]; long int curHash; struct occurance_t hashes[3000] = {{0, 0, {{0}}}}; struct occurance_t temp; int stop=0, hashCount=0, sort; int i=0, l; scanf("%s", curWord); curHash=hash(curWord); for(i=0; i<3000 && stop==0; i++){ for(l=0; l<=i; l++){ if(hashes[l].count==0){ hashes[l].hash=curHash; strcpy(hashes[l].words[hashes[l].count], curWord); hashes[l].count++; if(hashes[l].count==4){ stop=1; break; } hashCount++; break; } if(hashes[l].hash==curHash){ if(isRepeating(hashes, l, curWord)==1){ break; } strcpy(hashes[l].words[hashes[l].count], curWord); hashes[l].count++; if(hashes[l].count==4){ stop=1; break; } break; } } if(stop==0){ scanf("%s", curWord); curHash=hash(curWord); } } while(sort!=1) { sort = 1; for(i = 0; i<hashCount-1; i++) { if (hashes[i].hash>hashes[i+1].hash) { temp = hashes[i]; hashes[i] = hashes[i+1]; hashes[i+1]=temp; sort = 0; } } } for(i=0; i<hashCount; i++){ if(hashes[i].count>1){ printf("%ld", hashes[i].hash); for(l=0; hashes[i].words[l][0]!=0 && l<4; l++){ printf(" %s", hashes[i].words[l]); } printf("\n"); } } return 0; }