User Tools

Site Tools


ia

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
ia [2021/07/08 21:20] – test 500 error becoia [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-Login: mnnn                             Name: Mat Nat Sil 
-Directory: /home/mnes                   Shell: /bin/bash 
-Office: mat@gmil.com, @Mat        Home Phone: (81) 91111-1111 
-Last login Thu Jul  8 00:29 (-03) on pts/0 from 123.123.123.123 
-No mail. 
-Project: 
-= Curto prazo = 
-    * Revise a 
-    * Revise c  
-    * org pla 
- 
-= Medio prazo = 
-    * Disc 
-    * Comp new 
-    * Arrange  
- 
-= Longo prazo = 
-    * end 
-    * job 
-    * keep 
- 
-Plan: 
-Courses: dis 
-Birthday: 19990101 
-CPF: **123**** 
-Freshman: 2018 
-Hydra: 20200112 
-Github: @Mat 
-Gitlab: @Mat 
-ProjectEuler: 010010101 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
-/* ---------------------------------------------------------------------- */ 
-/*  Quadrado Magico          */ 
-/*  7 | 2 | 3                */ 
-/* ---+---+---               */ 
-/*  0 | 4 | 8                */ 
-/* ---+---+---               */ 
-/*  5 | 6 | 1                */ 
-  
-int alguem_venceu(char tab[9])  
-{ 
-    int i, j, k; 
- 
-    for(i=0; i<7; i++) 
-        for(j=i+1; j<8; j++) 
-            for(k=j+1; k<9; k++) 
-            { 
-                if(mag[i]+mag[j]+mag[k]==12) 
-                    continue; 
-                if(tab[i]==tab[j] && tab[j]==tab[k]) 
-                    return tab[i]; /* venceu */ 
-            } 
-    return 0; /* nao venceu */ 
-} 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
-/* ---------------------------------------------------------------------- */ 
-typedef struct stab 
-{ 
-    char coord[10]; 
-} tab_t; 
- 
-typedef struct slances 
-{ 
-    int i; 
-    struct slances *prox; 
-} lances_t; 
- 
-typedef struct smelhor 
-{ 
-    int valor; 
-    lances_t *rota; 
-} melhor_t; 
-         
-/* ---------------------------------------------------------------------- */ 
-/* algoritmo recursivo minimax */ 
-melhor_t minimax(tab_t tab, int vez) 
-{ 
-    melhor_t mel, res; 
-    lances_t *lances=NULL, *plance=NULL; 
-    tab_t ntab; 
- 
-    gera_lances(tab, &lances);   /* successors == 0 , se alguem ganhou ou empatou */ 
-    if(lances==NULL) 
-    { 
-        mel.valor = estatico(tab); /* valor absoluto x=1, o=-1, empate=0 */ 
-        mel.rota = NULL; 
-        return mel; 
-    } 
-    mel.valor = 2 * -vez; 
-    plance=lances; 
-    while(plance!=NULL) 
-    { 
-        ntab = tab;  
-        ntab.coord[plance.i] = vez; 
-        res=minimax(ntab, -vez); 
-        if(res.valor > mel.valor * vez) 
-        { 
-            limpa_melhor(mel); 
-            mel.rota=duplica_lance(plance); 
-            mel.rota->prox=res.rota; 
-        } 
-        else 
-            limpa_melhor(res); 
- 
-        /* mel=pega_melhor(res, mel, plance, vez); */ 
-        plance = plance.prox; 
-    } 
-    limpa_lances(&lances); 
-    return melhor; 
-} 
- 
-/* ---------------------------------------------------------------------- */ 
-melhor_t pega_melhor(melhor_t r, melhor_t m, lances_t *pl, int v) 
-{ 
-    if(r.valor > m.valor * v) 
-    { 
-        limpa_melhor(m); 
-        m.rota=duplica_lance(pl); 
-        m.rota->prox=r.rota; 
-    } 
-    else 
-        limpa_melhor(r); 
-    return m; 
-} 
- 
-/* ---------------------------------------------------------------------- */ 
-void gera_lances(tab_t tab, lances_t **ppl) 
-{ 
-    int i; 
- 
-    for(i=0; i<9; i++) 
-        if(tab.coord[i]==0) 
-            novo_lance(ppl, i); 
-} 
- 
-/* ---------------------------------------------------------------------- */ 
-void novo_lance(lances_t **ppl, int i) 
-{ 
-    lances_t *pl; 
-    if(ppl==NULL)  /* never happens, called with &lances */ 
-        return; 
-    pl=*ppl; 
-    while(pl!=NULL) 
-        pl=pl->prox; 
-    pl=(lances_t *)malloc(sizeof(lances_t)); 
-    pl->i=i; 
-    pl->prox=NULL; 
-    return; 
-} 
- 
- 
-/* ---------------------------------------------------------------------- */ 
-/* vi: set ai et ts=4 sw=4 tw=0 wm=0 fo=croql : C config for Vim modeline */ 
-/* Template by Dr. Beco <rcb at beco dot cc> Version 20160612.142044      */ 
  
ia.1625790048.txt.gz · Last modified: 2021/07/08 21:20 by beco