Announcement

Collapse
No announcement yet.

AllPrefixSum - Senator Style - Es2 - Exam

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • AllPrefixSum - Senator Style - Es2 - Exam

    PHP Code:
    /***
     *               _            _                          
     *              (_)          (_)                          
     *    __  ____ _ _  _____   ___  ___   ___ ___  _ __ ___  
     *    \ \/ / _` | |/ _ \ \ / / |/ _ \ / __/ _ \| '_ ` _ \
     *     >  < (_| | | (_) \ V /| | (_) | (_| (_) | | | | | |
     *    /_/\_\__, |_|\___/ \_/ |_|\___(_)___\___/|_| |_| |_|
     *          __/ |                                        
     *         |___/                                          
     */

    #include <st***.h>
    #include <stdlib.h>
    #include <string.h>

    typedef struct lista {
             
    int *indirizzo;
             
    struct lista prossimo;
    lista_struct;

    //////////////////////////////////////////// prototypes
    lista_struct *new_node int address);
    lista_struct add_node(lista_struct nodo ,lista_struct lista);
    void allprefixsums int aint n);

    int main (void){
        
        
    int i;
        
    int vet[10]={2,5,1,3,2,6,0,4};
        
    lista_struct *list;
        
    lista_struct *temp_node;
        
        
    //////////////////////////
        
        
    list= NULL;
        
        for (
    i=0;i<8;i++){
            
    printf ("%d ", *(vet +i));
        }
        
    printf ("\n");
        
        
    allprefixsums vet8);
        
        for (
    i=0;i<8;i++){
            
    printf ("%d ", *(vet +i));
        }
        
    printf ("\n");
        
        
        for (
    i=0;i<8;i++){
            
            
    temp_node new_node (vet +i);
            list = 
    add_node(temp_node,list);
        }
        
        
        for(
    temp_node = list;temp_node != NULLtemp_node temp_node->prossimo){
            
            
    printf("Indirizzo nodo %p\n",temp_node->indirizzo);
            
        }
        return 
    0;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////functions



    void allprefixsums int aint n){
        
        
    int i;
        for (
    i=1;i<8;i++){
            
            *(
    a+i)= *(a+i)+ (*(a+i-1));
            
        }
    }

    lista_struct *new_node int address){
        
        
    lista_struct node;
        
        
    node = (lista_struct *) malloc (sizeof(lista_struct));
        
        
    node->indirizzo address;
        
    node->prossimo NULL;
        
    }

    lista_struct add_node(lista_struct nodo ,lista_struct lista){
        
        if ( 
    lista == NULL){
            return 
    nodo;  
        }
        
        
    lista->prossimo add_node(nodo,lista->prossimo);
        return 
    lista;
        

    | VFX Artist, C++ Programmer, HW Overclocker | Web: xgiovio.com Email: xgiovio@gmail.com Twitter: @xgiovio
Working...
X

Google Profile


My name is Giovanni Di Grezia, but people call me xgiovio.

Here is my homepage:.

I'm a VFX Artist and Software Developer.

Giovanni Di Grezia