// Unwind N+1 times void crv_main() { STinit(); for (crv::Internal<unsigned> i = 0; dfs_checker().BRANCH_CALL(i < N); i = i+1) { STinsert(crv::any<Item>()); } STsort(sorter); dfs_checker().add_error(!(k == N)); for (crv::Internal<unsigned> i = 0; dfs_checker().BRANCH_CALL(i < N - 1); i = i+1) dfs_checker().add_error(!(a[i] <= a[i+1])); }
void STpreInsertWord(char *word,char *lemma,int sentenceNumber){ int *k = malloc(2*sizeof(int)); EnglishWord newWord; k[0] = 2; k[1] = sentenceNumber; newWord = STinitCell(); newWord.word = arrangeString(word); newWord.sentenceArray = arrangeString(lemma); newWord.sentenceLocal = (int*)realloc(k,k[0]*sizeof(int)); STinsert(newWord); }
void *STfindOrInsert( SEARCH_TABLE *t, /* read-write table */ const void *r) /* record to find */ { void *c = STfind(t,r); PRECOND(t->InitRec != NULL); PRECOND(t->ReturnId != NULL); if (c != NULL) return c; c = STinsert(t,r); if (c != NULL) t->InitRec(c,t->ReturnId(r)); return c; }
void adiciona_cheque(int valor,long int refe,long int refb,long int refc) { Cliente emp, rec; Cheque a; a = criaCheque(valor,refe,refb,refc); QUEUEput(cheques, a); if (STsearch(clientes, refe) != NULL) { emp = (STsearch(clientes, refe)); emp -> val_emi += valor; emp -> num_emi += 1; } else STinsert(&clientes, criaCliente(refe,1,valor,0,0)); if (STsearch(clientes, refb) != NULL) { rec = (STsearch(clientes, refb)); rec -> val_rec += valor; rec -> num_rec += 1; } else STinsert(&clientes, criaCliente(refb,0,0,1,valor)); }
// It suffices to unwind N+1 times where N > 2 int main() { STinit(); nse_make_symbolic(a); for (unsigned i = 0; i < N; i++) { STinsert(nse_symbolic_item()); } STsort(sorter); nse_assert(k == N); for (unsigned i = 0; i < N - 1; i++) nse_assert(a[i] <= a[i+1]); return 0; }
/*Funćão de inserćão de palavra, lema e posićão na WordTree*/ void STappendLemmaTree(char *word,char *lemma, int sentenceNumber){ int result = 0; char **senteceList = malloc(sizeof(char*)); EnglishWord newWord; result = STsearchLemmaTree(lemma); if (result){ fixSentenceLemmas(head,lemma,word); return; } newWord = STinitWord(); newWord.word = arrangeString(lemma); senteceList[0] = arrangeString(word); newWord.sentenceArray = (char**)realloc(senteceList,sizeof(char*)); newWord.sentenceLocal = malloc(sizeof(int)); newWord.sentenceLocal[0] = 1; /*quantidade de palavras indexadas pelo mesmo lema*/ STinsert(newWord); }
void send_msg(){ /*Para trabalhar com outro tipo de items mudar esta funcao*/ Item item; fgets(char *name, int name_size, FILE *stdin); fgets(char *hashtag, int hashtag_size, FILE *stdin); fgets(char *msg, int msg_size, FILE *stdin); item->name=name; item->hashtag=hashtag; item->msg=msg; STinsert(item); }
int main(int argc, char *argv[]) { int N, i; Item item, itm; Key searched_key = malloc(2 * sizeof(char)), key = malloc(2 * sizeof(char)); char init = 'a'; srand(time(NULL)); if (argc != 2) printf("Insufficient args. Enter N > 4!"); else { N = atoi(argv[1]); if (N > 30) { printf("Enter 4 < value < 30\n"); return 0; } STinit(N); for (i = 0; i < N; i++) { key[0] = init + i; key[1] = '\0'; item = ITEMrand(key); ITEMshow(item); if (i == S) strcpy(searched_key, key); STinsert(item); } printf("\n"); printf("Searching for element with key \'%s\'! ", searched_key); itm = STsearch(searched_key); ITEMshow(itm); printf("Deleting item!\n"); STdelete(itm); printf("Searching for element with key \'%s\'! ", searched_key); ITEMshow(STsearch(searched_key)); } return 0; }