Example #1
0
int main(){
    int n, k;
    int edge[100][100];
    int esize[100] = {};
    bool check[100] = {};
    int i, j, before;
    scanf("%d %d", &n, &k);
    for (i = 0; i < k; i++){
        int from, to;
        scanf("%d %d", &from, &to);
        from--; to--;
        edge[from][esize[from]++] = to;
        edge[to][esize[to]++] = from;
    }

    printf("%d\n", (n - 1) - k);
    before = 0;
    checking(edge, esize, check, 0);
    for (i = 0; i < n; i++){
        if (!check[i]){
            printf("%d %d\n", before+1, i+1);
            checking(edge, esize, check, i);
            before = i;
        }
    }
    return 0;
}
/**
    \brief This function calculates the number of duplicates based from the filenames and their sizes.
    \param files The file structure consisting of a map of file size and file name.
    \return An unsigned int equal to the number of duplicates found.
**/
unsigned int DuplicateFinder::DuplicateComparison( const std::multimap<unsigned int, std::wstring> & files )
{
    unsigned int numDupes = 0;
    //check to see if a file's size has other matching files' sizes
    auto mit = files.begin(); //mit is an iterator through the file list
    while( mit != files.end() ) //while searching through the list
    {
        //checking the file immediately after the currently iterated file
        if( ( std::next( mit ) != files.end() ) )
        {
            if( ( std::next( mit ) )->first == mit->first ) // if filesize is same as next's:
            {
                //open the iterated entry
                boost::filesystem::ifstream original( mit->second, std::ios::binary );
                if( original.is_open() ) //if we opened it...
                {
                    //open the next file to compare
                    boost::filesystem::ifstream checking( ( std::next( mit ) )->second,
                                                            std::ios::binary );
                    if( checking.is_open() ) //if successfully opened,
                    {
                        char originalByte; //for original's same byte
                        char nextByte; //for next's same byte
                        //start by reading check's first byte
                        checking.read( &nextByte, sizeof( char ) );
                        //start by reading original's first byte
                        original.read( &originalByte, sizeof( char ) );

                        //while we're not at the end of the files
                        while( !checking.eof() || !original.eof() )
                        {
                            //check to make sure the bytes are not different
                            if( nextByte != originalByte )
                            {
                                break; //move on to the next file
                            }

                            //read in the next bytes
                            checking.read( &nextByte, sizeof( char ) );
                            original.read( &originalByte, sizeof( char ) );
                        }
                        //if we were at the end of both files, we report a duplicate into the
                        //duplicate list and add an extra entry to "numberOfDuplicates"
                        if( checking.eof() && original.eof() )
                        {
                            duplicates.push_back( next( mit )->second +
                                                  std::wstring( L" is a duplicate of ") +
                                                  mit->second);
                            ++numDupes;
                        }
                    }
                }
            }
        }
        ++mit;
    }

    return numDupes;
}
Example #3
0
void checking(int edge[100][100], int esize[100], bool check[100], int k){
    if (!check[k]){
        int i;
        check[k] = true;
        for (i = 0; i < esize[k]; i++){
            checking(edge, esize, check, edge[k][i]);
        }
    }
}
Example #4
0
File: negint.c Project: aosm/gcc_40
int main (void)
{
  ffi_cif cif;
  ffi_type *args[MAX_ARGS];
  void *values[MAX_ARGS];
  ffi_arg rint;

  signed int si;
  signed short ss;
  signed char sc;

  args[0] = &ffi_type_sint;
  values[0] = &si;
  args[1] = &ffi_type_sshort;
  values[1] = &ss;
  args[2] = &ffi_type_schar;
  values[2] = &sc;

  /* Initialize the cif */
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
		     &ffi_type_sint, args) == FFI_OK);

  si = -6;
  ss = -12;
  sc = -1;

  checking (si, ss, sc);

  ffi_call(&cif, FFI_FN(checking), &rint, values);

  printf ("%d vs %d\n", (int)rint, checking (si, ss, sc));

  CHECK(rint != 0);

  exit (0);
}
Example #5
0
void SDiscDetector::button_clicked( QAbstractButton *button )
{
    QMessageBox::ButtonRole role = p->message->buttonRole( button );
    switch( static_cast<int>(role) )
    {
    case QMessageBox::Rejected:
        close_dialog();
        checking();
        break;

    case QMessageBox::Accepted:
        close_dialog();
        disconnect( p->device_list , SIGNAL(deviceDetected(SDeviceItem)) , this , SLOT(checking()) );
        emit rejected();
        break;
    }
}
Example #6
0
int		main(int argc, char **argv)
{
	int x;
	int	**tab;

	tab = allocate_tab();
	if (error(1, 0, argv, argc) == 0)
	{
		tab = init(argv, tab);
		if (*init(argv, tab) != 0)
		{
			checking(tab, 0);
			x = 0;
			while (x < argc - 1)
			{
				ft_putnbr(tab[x]);
				ft_putchar('\n');
				x++;
			}
			free(tab);
		}
	}
	return (0);
}
Example #7
0
int main(int argc, char **argv)
{
    int tid;
    FILE *file;

    if(argc > 2)
    {
        printf("Too many arguments please enter only one path\n");
        exit(1);
    }
    if((file = fopen(argv[1], "r"))==NULL)       /* open a text file for reading */
    {
        printf("File or Directory doesn't exist\n");
        exit(1); //couldn't open the requested file!

    }
    fscanf(file, "%1d", &n);

    num = n*n;

    int mcount;
    checking(argv);
    lchecking(argv);

    #pragma omp parallel shared (a,b,c,num,chunk) private(tid,i,j,k)
    {
        void omp_set_num_threads(int num);
        tid = omp_get_thread_num();

        //Initializing  array "c"
        #pragma omp for schedule (static, chunk)
        for (i=0; i<n; i++)
            for (j=0; j<n; j++)
                c[i][j]= 0;
        //Entering the values to array "a"
        #pragma omp for schedule (static, chunk)
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < n; j++)
            {
                //Use lf format specifier, %c is for character
                if (!fscanf(file, "%d", &a[i][j]))
                {
                    printf("Invalid input\n");
                    exit(1);
                    break;
                }
            }
        }

        //Entering the values to array "b"
        #pragma omp for schedule (static, chunk)
        for( i = 0; i<n ; i++)
        {
            for(k = 0; k < n; k++)
            {
                //Use lf format specifier, %c is for character
                if (!fscanf(file, "%d", &b[i][k]))
                {
                    printf("Invalid input 2\n");
                    exit(1);
                    break;
                }
            }
        }

        #pragma omp for schedule (static, chunk)
        for (i=0; i<n; i++)
        {
            for(j=0; j<n; j++)
                for (k=0; k<n; k++)
                    c[i][j] += a[i][k] * b[k][j];
        }
    }
    //Print out the resultant matrix
    printf("Resultant matrix using OpenMP is\n");
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < n; j++)
        {
            printf("%d\t", c[i][j]);
        }
        printf("\n");
    }

    fclose(file);


    return 0;
}
Example #8
0
void wait_initialized(
) {
    boost::unique_lock<boost::mutex> checking(initializing);
}
Example #9
0
void SDiscDetector::dialog_destroyed()
{
    p->dialog = 0;
    checking();
}
Example #10
0
void SDiscDetector::checking()
{
    int unsolved = 0;
    QString message;
    unsigned long int minimum_dst_size = 0;



    if( !p->source.isEmpty() )
    {
        const SDiscFeatures & disc = p->source.currentDiscFeatures();
        if( disc.volume_disc_is_blank || disc.volume_size_int <= 0 )
        {
            unsolved++;
            message += tr( "Can't detect disc on source device (%1)\n" ).arg( p->source.name() );
        }
        else
            minimum_dst_size = 1+ disc.volume_size_int / RATIO_SIZE;
    }
    if( !p->source_img.isEmpty() )
    {
        minimum_dst_size = 1+ QFileInfo(p->source_img).size() / RATIO_SIZE;
    }
    if( p->custom_min_size != 0 )
    {
        minimum_dst_size = p->custom_min_size / RATIO_SIZE;
    }
    if( !p->destionation.isEmpty() )
    {
        const SDiscFeatures & disc = p->destionation.currentDiscFeatures();
        if( !disc.volume_disc_is_blank || minimum_dst_size > disc.volume_capacity_int/RATIO_SIZE )
        {
            unsolved++;
            message += tr( "Can't detect disc on \"%1\".\nPlease Insert an empty disc.\n" ).arg( p->destionation.name() );
            if( minimum_dst_size != 0 )
                message += tr( "Free space needed: %2MB\n" ).arg( QString::number(minimum_dst_size) );
        }
    }
    if( !p->rewribale.isEmpty() )
    {
        const SDiscFeatures & disc = p->rewribale.currentDiscFeatures();
        if( !p->rewribale.deviceFeatures().media_available_stt || !disc.volume_disc_type_str.contains("rw",Qt::CaseInsensitive) )
        {
            unsolved++;
            message += tr( "Can't detect rewritable Disc on \"%1\".\nPlease Insert a rewritable disc.\n" ).arg( p->rewribale.name() );
        }
    }
    if( !p->disc.isEmpty() )
    {
        if( p->disc.deviceFeatures().media_available_stt )
        {
            unsolved++;
            message += tr( "Can't detect any Disc on \"%1\".\n" ).arg( p->disc.name() );
        }
    }



    if( unsolved == 0 )
    {
        if( p->dialog != 0 )
            close_dialog();

        disconnect( p->device_list , SIGNAL(deviceDetected(SDeviceItem)) , this , SLOT(checking()) );
        emit accepted();
    }
    else if( p->dialog == 0 && unsolved != 0 )
    {
        init_dialog( message );
    }
}
Example #11
0
void SDiscDetector::check()
{
    connect( p->device_list , SIGNAL(deviceDetected(SDeviceItem)) , SLOT(checking()) );
    checking();
}
Example #12
0
double Sigma(double mass)
{
    double sigma = 0.0;
    double cobenorm();
    double epsabs=0.0, abserr, epsrel=1.489999e-08,sig2;
    int nbins = 2000;

    gsl_integration_workspace *w = gsl_integration_workspace_alloc (nbins);
    gsl_function F;


    checking(); /* Check if cosmology is sensible */

    /* Set all the background quantities */
    if(TransferFunc_Init(redshift)) printf("Some warnings in Init\n");

    deltaH = cobenorm();
    quiet=1;
    if (!quiet) {	/* Echo cosmological information to the screen */
        printf("Omega_0  = %5.3f, Omega_baryon = %5.3f, Omega_neutrino = %5.3f\n",
               Omega_Matter, Omega_Baryon, Omega_Neutrino);
        printf("Hubble   = %5.3f, Lambda       = %5.3f, N_neutrinos    = %d\n",
               h_z0, Omega_Lambda, (int) degen_Neutrino);
        printf("Redshift = %5.3f, Growth = %6.4f relative to z=0\n",
               redshift, growth_to_z0);
        printf("Tilt     = %5.3f, COBE normalization: deltaH = %8.3e",
               tilt, deltaH);
        if (tilt!=1.0)
            if (qtensors) printf(" with tensors.\n");
            else printf(" without tensors.\n");
        else printf("\n");
    }
    /* If we've been asked to compute for a particular scale, do that */


    if (scale>0 || mass>0) {
        if (mass<0)
            mass = 4.0*M_PI/3.0*Omega_Matter*RHOCRIT*scale*scale*scale;
        else if (scale<0)
            scale = pow(3.0/4.0/M_PI/RHOCRIT/Omega_Matter*mass, 1.0/3.0);
        /* Integrate tophat for the given scale */
        sig2_scale = scale;

        /* Choose the right filter */

        if(strcmp(SigmaFilter,"top-hat")==0)
            F.function = &sig2tophat;

        if(strcmp(SigmaFilter,"gaussian")==0)
            F.function = &sig2gauss;

        if(strcmp(SigmaFilter,"sharp-k")==0)
            F.function = &sig2sharpk;

        /* Performing the integral */
        gsl_integration_qags(&F,0.0,1.0,epsabs,epsrel,nbins,w,&sig2,&abserr);

        sigma = sqrt(sig2);
    }

    gsl_integration_workspace_free (w);

    return sigma;
}
Example #13
0
void flag(int lv, int row, int col){ // 32 0 95
	if(lv == 3){
		f[row][col] = true;
	}
	else{
		flag(lv/2,  row , col );
		flag(lv/2,  row+lv/2, col-lv/2); 
		flag(lv/2,  row+lv/2, col+lv/2);
		#include<cstdio>
#define RMAX 3072
#define CMAX 7000

char ch[RMAX][CMAX] = {0,};
bool f[RMAX][CMAX] = {0,};
int n;
int h, w;

void checking( int row,int col){
	ch[row][col] = ch[row+1][col-1] = ch[row+1][col+1] = ch[row+2][col-2] = ch[row+2][col-1] = ch[row+2][col] = ch[row+2][col+1] = ch[row+2][col+2] = '*';
}
void flag(int lv, int row, int col){ // 32 0 95
	//if(lv == 0) return ;
	//if(row > n) return ; 
	//if(col < 0) return ;
	//if(col > w) return ;
	//f[row][col] = !f[row][col];
	//flag(lv-1,row+3, col-3); // 31 3 92 
	//flag(lv-1,row+3, col+3); // 31 3 98
	//return;
	//printf("%d\n",lv); 2^32
	// 나오긴 하는데.. 진짜 오래걸린다.
	if(lv == 3){
		f[row][col] = true;
		return;
	}
	else{
		flag(lv/2,  row , col );
		flag(lv/2,  row+lv/2, col-lv/2); 
		flag(lv/2,  row+lv/2, col+lv/2);
		return;
	}
}

void print(){
	for(int r = 0 ; r < h ; r+=3){
		for(int c = 0 ; c < w ; c++){
			if(f[r][c]){
				checking(r,c);
			}			
		}
	}
	for(int r = 0 ; r < h ; r++){

		if(r!=h-1)puts(ch[r]);
		else printf("%s",ch[r]);
	}
}
void init(){
	for(int r = 0 ; r < h ; r++)
		for(int c = 0 ; c < w ; c++)
			ch[r][c] = ' ';
}
int main(){
	scanf("%d", &n);
	h = n;
	w = 2*h-1;
	init();
	flag(n, 0, n-1); // 96/3 32 ,, 95
	print();
	return 0;
}



	}