Пример #1
0
int main(){

//Testar exo 1
	char s1[10] ="marianas";
	char s2[4] ="ana";

	char* o = strstr(s1, s2);

	printf("%s  %s  %s\n ", s1, s2, o);

//
	//Testar exo2
	int v[4] ={ 90, 4, 80, 2};
	int in = maxInd(v, 4);
	printf("O indice do maior valor no vetor v é %d cujo elemento é %d\n", in, v[in]);

//Testar exo 3
	printf("Antes do concat\n");
	LInt a = (LInt)malloc(sizeof(struct slist));
	a->valor = 10;
	a->prox = (LInt)malloc(sizeof(struct slist));
	a->prox->valor = 20;
	a->prox->prox = NULL;

	printL(a);

	LInt b = (LInt)malloc(sizeof(struct slist));
	b->valor = 30;
	b->prox = (LInt)malloc(sizeof(struct slist));
	b->prox->valor = 40;
	b->prox->prox= NULL;
	printL(b);

	concat3(&a, b);

	printf("Depois do concat\n");

	//a = concat(a,b);
	printL(a);

	//Testar exo4

	printf("Exo 4\n");
	ABin ar = (ABin)malloc(sizeof(struct nodo));
	ar->valor = 50;
	ar->esq = (ABin)malloc(sizeof(struct nodo));
	ar->esq->valor = 30;
		ar->esq->esq = NULL;
		ar->esq->dir=NULL;

	ar->dir = (ABin)malloc(sizeof(struct nodo));
	ar->dir->valor = 80;
		ar->dir->esq = NULL;
		ar->dir->dir = NULL;

	LInt lis = nivel(ar, 2);
	printL(lis);

	return 0;
}
Пример #2
0
void printWilliam(int x, int y) {
	printW(x,y);
	printI(x+5*SIZE+GAP,y);
	printL(x+6*SIZE+2*GAP,y);
	printL(x+9*SIZE+3*GAP,y);
	printI(x+12*SIZE+4*GAP,y);
	printA(x+13*SIZE+5*GAP,y);
	printM(x+16*SIZE+6*GAP,y);
}
Пример #3
0
main(){
	char str[50];

	printf("Enter your name: ");
	gets(str);
	
	printW();
	printf("\n");
	delay(50);
	printE();
	printf("\n");
	delay(50);
	printL();
	printf("\n");
	delay(50);
	printC();
	printf("\n");
	delay(50);
	printO();
	printf("\n");
	delay(50);
	printM();
	printf("\n");
	delay(50);
	printE();	
	printf("\n");
	delay(50);
}
Пример #4
0
void printMarcel(int x, int y) {
	printM(x,y);
	printA(x+5*SIZE+GAP,y);
	printR(x+8*SIZE+2*GAP,y);
	printC(x+12*SIZE+3*GAP,y);
	printE(x+16*SIZE+4*GAP,y);
	printL(x+19*SIZE+5*GAP,y);
}
Пример #5
0
void printAngela(int x, int y) {
	printA(x,y);
	printN(x+3*SIZE+GAP,y);
	printG(x+7*SIZE+2*GAP,y);
	printE(x+12*SIZE+3*GAP,y);
	printL(x+15*SIZE+4*GAP,y);
	printA(x+18*SIZE+5*GAP,y);
}
Пример #6
0
int main(){
    int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int z = 10;

    L seq;
    initL(&seq, a, 10);
    printL(&seq);

    printf("binary search %d times is %d\n", z, binarySearch(&seq, z));
}
scp_result printNl(scp_operand *param)
{
    return printL(param, SC_TRUE);
}
scp_result print(scp_operand *param)
{
    return printL(param, SC_FALSE);
}
Пример #9
0
void small_Energy_Progress_Measure(node** nodes, int N) {
   
    int i;
    lista_bidirezionale** lista_L = (lista_bidirezionale**) malloc(sizeof(lista_bidirezionale*)); 
    int* inlistaL = calloc(N,sizeof(int));


    for (i=0; i<N; i++){
        //printlist(nodes[i]->out_neighbour);
        edgeList* iteratore; // = malloc(sizeof(edgeList));
        iteratore = nodes[i]->out_neighbour;

        if (nodes[i]->player == 0){
            int counter = 0;

            while(iteratore != NULL){
                if (iteratore->weight < 0){
                    counter++;
                    iteratore = iteratore->next;
                } else {
                    break;
                }
            }
            if (counter == nodes[i]->out_degree){
                lista_L = aggiungiNodo(lista_L, nodes[i]->id);
                inlistaL[nodes[i]->id]=1;
            }
        }else {
            while(iteratore != NULL){
                if (iteratore->weight < 0){
                    lista_L = aggiungiNodo(lista_L, nodes[i]->id);
                    inlistaL[nodes[i]->id]=1;
                    break;
                }else{
                    iteratore = iteratore->next;
                }       
            } 

        }
        //printlist(nodes[i]->out_neighbour);
    }

    int* f = calloc(N,sizeof(int));
    int* count = malloc(N*sizeof(int));
    int T = makeTop(nodes,N);

    printf("Il top è %i \n", T);

    printL(*lista_L,nodes);

    for (i=0; i<N; i++){
        if (nodes[i]-> player == 0){
            if (inLista(nodes[i]->id, *lista_L)){
                count[i] = 0;
            } else {
                count[i] = setCount_v(nodes,nodes[i]->id,T,f);
            }
        }
    }

    printL(*lista_L,nodes);
    /*
    lista_bidirezionale* it = *lista_L; 
    while (it != NULL){
        fprintf(stderr, "  %i \n",it->id);
        it = it-> next;
    }
    */

    int old_f, v;
    lista_bidirezionale* it = *lista_L; 
    while (it != NULL){
        v = (*lista_L) -> id;
        old_f = f[v];
        it = eliminaNodo(*lista_L, lista_L);
        inlistaL[v]=0;
        f[v] = Lift(f,v,nodes,T);

        printf("f[%s] vale %i \n",nodes[v]->label,f[v]);
        if (nodes[v]->player == 0)
            count[v] = setCount_v(nodes,v,T,f);
        edgeList* v_1 = nodes[v]->in_neighbour;
        while (v_1 != NULL){
            //fprintf(stderr,"v_1 e' %s \n",nodes[v_1->id]->label);
            if (f[v_1->id] < confronta_misure(f[v],v_1->weight,T)){
                if (nodes[v_1->id]->player == 0) {
                    if (f[v_1->id] >= confronta_misure(old_f,v_1->weight,T))
                        count[v_1->id]-= 1;
                    if (count[v_1->id] <= 0){
                        //fprintf(stderr,"count[%s] <= 0 Aggiungo il nodo %s a L\n",nodes[v_1->id]->label,nodes[v_1->id]->label);
                        if (inlistaL[nodes[v_1->id]->id]==0){
                            lista_L = aggiungiNodo(lista_L, nodes[v_1->id]->id);
                            inlistaL[nodes[v_1->id]->id]=1;
                            it = *lista_L;
                        }
                    }
                } else{
                    if (inlistaL[nodes[v_1->id]->id]==0){
                        lista_L = aggiungiNodo(lista_L, nodes[v_1->id]->id);
                        inlistaL[nodes[v_1->id]->id]=1;
                        it = *lista_L;
                    }
                }
            }
            v_1 = v_1 -> next;
        }
        printL(*lista_L,nodes);
    }

    for (i=0; i<N; i++){
        if (f[i] == T)
            fprintf(stdout, "Il nodo %s ha misura = T  \n",nodes[i]->label);
        else
            fprintf(stdout, "Il nodo %s ha misura = %i  \n",nodes[i]->label , f[i]);
    }

}