int yy_lex(){ if (yy_buffer == NULL){ yy_create_buffer(); } int current_state = dfa_start, next_state, last_ac_state, act; char *last_ac_cp; while (1){ last_ac_state = -1; last_ac_cp = NULL; if(*yy_cp == '\0'){ return YY_NULL; } next_state = current_state; do{ if(accept(next_state)){ last_ac_cp = yy_cp; last_ac_state = next_state; } current_state = next_state; next_state = dfa_table[current_state][CHAR_TO_INT(*yy_cp)]; yy_cp++; }while(next_state != -1); if(last_ac_state != -1){ act = accept(last_ac_state); yy_cp = last_ac_cp; current_state = dfa_start; }else{ return YY_ERROR; } switch(act){ case 1: ; break; case 2: printf("find 'if'\n"); break; case 3: printf("find 'else'\n"); break; case 4: printf("find 'while'\n"); break; case 5: printf("find id\n"); break; default: return YY_ERROR; } } }
int main(int argc, char *argv[]) { (void) argc; (void) argv; int grid [20][20]; FILE * file = fopen("../grid.txt", "r"); int x = 0; int y = 0; char c; for(c = getc(file); c != EOF; c = getc(file)) { if(c == ' ') { x ++; } else if ( c =='\n') { x = 0; y ++; } else { char d = getc(file); grid[x][y] = CHAR_TO_INT(c) * 10 + CHAR_TO_INT(d); } } int best= 0; //vertical for(x = 0; x < 20; x ++) { for(y = 0; y < 20 - LENGTH; y ++) { int i; int current = 1; for(i = 0; i < LENGTH; i ++) { current *= grid[x][y + i]; } if(current > best) best = current; } } //horizontal for(x = 0; x < 20 - LENGTH; x ++) { for(y = 0; y < 20; y ++) { int i; int current = 1; for(i = 0; i < LENGTH; i ++) { current *= grid[x + i][y]; } if(current > best) best = current; } } //top left to bottom right for(x = 0; x < 20 - LENGTH; x ++) { for(y = 0; y < 20 - LENGTH; y ++) { int i; int current = 1; for(i = 0; i < LENGTH; i ++) { current *= grid[x + i][y + i]; } if(current > best) best = current; } } //top right to bottom left for(x = LENGTH - 1; x < 20; x ++) { for(y = 0; y < 20 - LENGTH; y ++) { int i; int current = 1; for(i = 0; i < LENGTH; i ++) { current *= grid[x - i][y + i]; } if(current > best) best = current; } } printf("Solution = %d\n", best); return 0; }
VOID NdisConvertStringToAtmAddress( OUT PNDIS_STATUS Status, IN PNDIS_STRING String, OUT PATM_ADDRESS AtmAddress ) /*++ Routine Description: Arguments: Status - Returns the status of the request. String - String representation of the atm address. * Format defined in Section 5.4, * "Example Master File Format" in ATM95-1532R4 ATM Name System: * * AESA format: a string of hexadecimal digits, with '.' characters for punctuation, e.g. * * 39.246f.00.0e7c9c.0312.0001.0001.000012345678.00 * * E164 format: A '+' character followed by a string of * decimal digits, with '.' chars for punctuation, e.g.: * * +358.400.1234567 AtmAddress - The converted Atm address is returned here. Return Value: None. --*/ { USHORT i, j, NumDigits; PWSTR p, q; UNICODE_STRING Us; ANSI_STRING As; // // Start off by stripping the punctuation characters from the string. We do this in place. // for (i = NumDigits = 0, j = String->Length/sizeof(WCHAR), p = q = String->Buffer; (i < j) && (*p != 0); i++, p++) { if ((*p == ATM_ADDR_BLANK_CHAR) || (*p == ATM_ADDR_PUNCTUATION_CHAR)) { continue; } *q++ = *p; NumDigits ++; } // // Look at the first character to determine if the address is E.164 or NSAP // p = String->Buffer; if (*p == ATM_ADDR_E164_START_CHAR) { p ++; NumDigits --; if ((NumDigits == 0) || (NumDigits > ATM_ADDRESS_LENGTH)) { *Status = NDIS_STATUS_INVALID_LENGTH; return; } AtmAddress->AddressType = ATM_E164; AtmAddress->NumberOfDigits = NumDigits; } else { if (NumDigits != 2*ATM_ADDRESS_LENGTH) { *Status = NDIS_STATUS_INVALID_LENGTH; return; } AtmAddress->AddressType = ATM_NSAP; AtmAddress->NumberOfDigits = NumDigits/sizeof(WCHAR); } // // Convert the address to Ansi now // Us.Buffer = p; Us.Length = Us.MaximumLength = NumDigits*sizeof(WCHAR); As.Buffer = ALLOC_FROM_POOL(NumDigits + 1, NDIS_TAG_CO); As.Length = 0; As.MaximumLength = NumDigits + 1; if (As.Buffer == NULL) { *Status = NDIS_STATUS_RESOURCES; return; } *Status = NdisUnicodeStringToAnsiString(&As, &Us); if (*Status != STATUS_SUCCESS) { FREE_POOL(As.Buffer); *Status = NDIS_STATUS_FAILURE; return; } // // Now get the bytes into the destination ATM Address structure. // if (AtmAddress->AddressType == ATM_E164) { // // We just need to copy in the digits in ANSI form. // NdisMoveMemory(AtmAddress->Address, As.Buffer, NumDigits); } else { // // This is in NSAP form. We need to pack the hex digits. // UCHAR xxString[3]; ULONG val; xxString[2] = 0; for (i = 0; i < ATM_ADDRESS_LENGTH; i++) { xxString[0] = As.Buffer[i*2]; xxString[1] = As.Buffer[i*2+1]; *Status = CHAR_TO_INT(xxString, 16, &val); if (*Status != STATUS_SUCCESS) { FREE_POOL(As.Buffer); *Status = NDIS_STATUS_FAILURE; return; } AtmAddress->Address[i] = (UCHAR)val; } } FREE_POOL(As.Buffer); *Status = NDIS_STATUS_SUCCESS; }
activation records file is hard-coded here. \*---------------------------------------------------------------------------*/ #include "fstypes.h" #include "fsapi.h" #include "fserror.h" #include "stringlib.h" // SigmaTel-specific #include "FileSystem.h" // SigmaTel-specific //#include <string.h> #define CHAR_TO_INT(a,b,c) ((((INT) (c)) << 16) | (((INT) (b)) << 8) | (INT) (a)) // "a:/Audible/AudibleActivation.sys" const INT ActivationFolder[] = { CHAR_TO_INT( 'a', ':', '/' ), CHAR_TO_INT( 'A', 'u', 'd' ), CHAR_TO_INT( 'i', 'b', 'l' ), CHAR_TO_INT( 'e', '/', '\0' ), }; const INT ActivationFilename[] = { CHAR_TO_INT( 'a', ':', '/' ), CHAR_TO_INT( 'A', 'u', 'd' ), CHAR_TO_INT( 'i', 'b', 'l' ), CHAR_TO_INT( 'e', '/', 'A' ), CHAR_TO_INT( 'u', 'd', 'i' ), CHAR_TO_INT( 'b', 'l', 'e' ), CHAR_TO_INT( 'A', 'c', 't' ), CHAR_TO_INT( 'i', 'v', 'a' ), CHAR_TO_INT( 't', 'i', 'o' ), CHAR_TO_INT( 'n', '.', 's' ),