view example/many_task/ppe/mymethod.cc @ 1852:7e9ebc1b08b6 draft

fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 21 Dec 2013 19:53:05 +0900
parents 0e1318e7caed
children
line wrap: on
line source

#include "sort.h"
#include "TaskManager.h"
#include "Func.h"
#include <stdlib.h>
#include <stdio.h>

void 
init_data ( Data *data , int size) 
{
    int i;
    srand(10);
    for (i=0; i<size; i++)
        { 
            data[i].index   = rand()%10000; 
            data[i].ptr	= 0;
        }
    return;
}

void
show_data( Data *data, int size )
{
    puts("-----------------------------------------------");
    for(int i=0; i<size; i++) printf("data[%02d].index = %d\n", i, data[i].index);
    puts("-----------------------------------------------");
    return;
}

void
write_data( Data *data, int size )
{
    FILE* fd;
    if ((fd = fopen("./sort.txt", "w")) < 0) {
    	fprintf(stderr,"Can't open file");
    }

    fprintf(fd,"-----------------------------------------------");
    for(int i=0; i<size; i++) fprintf(fd,"data[%02d].index = %d\n", i, data[i].index);
    fprintf(fd,"-----------------------------------------------");

    fclose( fd );
    return;
}