コード例 #1
0
ファイル: my.c プロジェクト: wangpan/panpan-project
int main(int argc, const char *argv[])
{
    char str[N]="hello world";
    char c_str[N];
    my_copy(c_str,str);
    printf("%s\n",c_str);
    return 0;
}/*(17 )将str【】的内容复制给c—str*/
コード例 #2
0
ファイル: my.c プロジェクト: wangpan/panpan-project
int main()
{

    char zifuchuan[N]="welcome to china!";
    char p_s[N];

    my_copy(zifuchuan,p_s);
    printf("%s\n",p_s);
    return 0;
}/*将zifuchuan数组中的内容复制到p_s数组中(8)*/
コード例 #3
0
ファイル: cp_file.c プロジェクト: cjhgo/sunsea-aka
void *thr_fn(void *arg)
{
	FILE *fp1;
	FILE *fp2;

	open_file(&fp1, &fp2);

	my_copy(&fp1, &fp2);

	close_file(&fp1, &fp2);

	return;
}
コード例 #4
0
ファイル: my_cp.c プロジェクト: oparin-alexander/all_programs
void copy_file(char* file1, char* file2)
{
	struct stat buf;
	
	if( stat(file1, &buf)<0) perror(file1); 
		
	int fd1 = open_file(file1, O_RDONLY, buf.st_mode);
	int fd2 = open_file(file2, O_CREAT|O_TRUNC|O_WRONLY, buf.st_mode);
	
	my_copy(fd1, fd2);
	
	close(fd1);
	close(fd2);
}
コード例 #5
0
/* print the longest input line, specialized version */
main()
{
    int len;        /* current line length */
    extern int max;
    extern char longest[];

    max = 0;
    while ((len = my_getline()) > 0)
        if (len > max) {
            max = len;
            my_copy();
        }
    if (max > 0) {        /* there was a line */
        printf("\n------EOF------\n");
        printf("The longest line is:\n");
        printf("%s", longest);
    }
    return 0;
}
コード例 #6
0
/* print the longest input line */
main()
{
    int len;        /* current line length */
    int max;        /* max length seen so far */
    char line[MAXLINE];     /* current input line */
    char longest[MAXLINE];  /* longest line saved here */

    max = 0;
    while ((len = my_getline(line, MAXLINE)) > 0)
        if (len > max) {
            max = len;
            my_copy(longest, line);
        }
    if (max > 0) {        /* there was a line */
        printf("\n------EOF------\n");
        printf("The longest line has %d characters.\n", max);
    }
    return 0;
}
コード例 #7
0
ファイル: my_shell.c プロジェクト: manfred-madelaine/systeme
/* Fonction: internal_command
 * Entrees: un entier représentant la position de la commande
 * a effectuer dans le tableau commande[]
 * 
 * Sortie: aucune
 * 
 * Execute une commande externe
 */
int internal_command(int pos) {
	if( strcmp(commande[pos], "exit") == 0)
	    {stockCommande(); my_exit(commande); return 1;}
	    
	else if(strcmp(commande[pos], "cd") == 0)
	    {stockCommande(); chdir(commande[pos+1]); return 1;}
	    
	else if(strcmp(commande[pos], "cat") == 0)
	    {stockCommande(); my_cat(commande[pos+1], commande[pos+2]); return 1;}
	    
	else if(strcmp(commande[pos], "history") == 0)
	    {stockCommande(); my_history(); return 1;}
	    
	else if(strcmp(commande[pos], "cp") == 0)
	    {stockCommande(); my_copy(commande[pos+1], commande[pos+2]); return 1;}  
	    
	else if(strcmp(commande[pos], "find") == 0)
		{stockCommande(); my_find(0); return 1;}
	    
	else return 0;
}
コード例 #8
0
  void send_data_begin() 
    {
      my_copy(src_b,src_e,buffer);
      MPI_Isend(buffer, sz*sizeof(T),MPI_BYTE, 
		p.the_rank, ++tag, p.the_communicator, &curr_request);
    }
コード例 #9
0
ファイル: main.cpp プロジェクト: CCJY/coliru
int main()
{    
    std::vector <MyStr> testVec = {
        MyStr(4, "value 4"),
        MyStr(4, "value 04"),
        MyStr(4, "value 004"),
        MyStr(3, "value 3"),
        MyStr(3, "value 03"),
        MyStr(9, "value 9"),
        MyStr(9, "value 09"), 
        MyStr(9, "value 009"), 
        MyStr(9, "value 0009"), 
        MyStr(7, "value 7"), 
        MyStr(7, "value 07"), 
        MyStr(1, "value 1")
    };
    
    // custom copyier
    std::multimap<int, MyStr> tempMap;
        
    PairMaker pairMaker;
    my_copy(testVec.cbegin(), testVec.cend(), std::inserter(tempMap, tempMap.end()), pairMaker);
    std::cout << "specialized copy->" <<std::endl;
    std::for_each(tempMap.cbegin(), tempMap.cend(), 
        [](const std::multimap<int, MyStr>::value_type& rValue){
            std::cout 
            << "key[" << rValue.first 
            << "] value:" << rValue.second.strval 
            << std::endl;
        });
    
    std::multimap<int,MyStr> mmap = {
        std::make_pair(4, MyStr(4, "value 4")),
        std::make_pair(4, MyStr(4, "value 04")),
        std::make_pair(4, MyStr(4, "value 004")),
        std::make_pair(3, MyStr(3, "value 3")),
        std::make_pair(3, MyStr(3, "value 03")),
        std::make_pair(9, MyStr(9, "value 9")), 
        std::make_pair(9, MyStr(9, "value 09")), 
        std::make_pair(9, MyStr(9, "value 009")), 
        std::make_pair(9, MyStr(9, "value 0009")), 
        std::make_pair(7, MyStr(7, "value 7")), 
        std::make_pair(7, MyStr(7, "value 07")), 
        std::make_pair(1, MyStr(1, "value 1"))
    };
    
    //auto ostriter = std::ostream_iterator<std::pair<int,std::string>>(std::cout, ",");
    for (auto iter = mmap.cbegin(); iter != mmap.cend(); ) {
        /* ... process *itr ... */
        auto range = mmap.equal_range(iter->first);
        std::cout << "processing [" 
            << std::distance (range.first, range.second) 
            << "] entries with key[" << range.first->first 
            << "]" << std::endl;
        //std::copy (range.first, range.second, ostriter);
//        std::for_each(range.first, range.second, 
//            [](const std::multimap<int, MyStr>::value_type& rValue){
//                std::cout 
//                << "key[" << rValue.first 
//                << "] value:" << rValue.second.strval 
//                << std::endl;
//            });
        // advance to the next range
        iter = range.second;
    }    
    return 0;
}
void method_case_second(function_two f, int minimum, int maximum, int variant) {
	for (int l = 1000; l <= 8000; l = l + 1000) {
		out<<"Размер массива: "<<l<<endl;

		int* etalon = new int[l];
		int* sorting = new int[l];

		_int64 min = INT_MAX;
		_int64 max = -2;
		_int64 sum = 0;
		int kol = 0;

		switch (variant) {
		case 0:
			array_generation(etalon, l, minimum, maximum);
			break;
		case 1:
			array_generation(etalon, l, minimum, maximum);
			break;
		case 2:
			array_generation(etalon, l, minimum, maximum);
			bubble_sort(etalon, l);
			break;
		case 3:
			array_generation(etalon, l, minimum, maximum);
			array_almost_sort(etalon, l);
			break;
		case 4:
			array_generation(etalon, l, minimum, maximum);
			array_reverse(etalon, l);
			break;
		}

		for (int k = 0; k < 20; k ++) { 
			my_copy(etalon, sorting, l);

			_asm { 
				 RDTSC 
				 mov DWORD PTR timestart, eax 
				 mov DWORD PTR timestart+4, edx 
			} 
		 
			f(sorting, 0, l - 1); 
			
			_asm {
				 RDTSC 
				 mov DWORD PTR timefinish, eax 
				 mov DWORD PTR timefinish+4, edx 
			}

			if ((timefinish - timestart) > max) { 
				max = (timefinish - timestart);
			}
			if ((timefinish - timestart) < min) { 
				min = (timefinish - timestart);
			}
			sum = sum + (timefinish - timestart); 
			kol ++;
		}

		out<<"Минимальное время: "<<min<<" Ticks"<<endl;
		out<<"Среднее время время: "<<sum / kol<<" Ticks"<<endl;
		out<<"Максимальное время: "<<max<<" Ticks"<<endl;

		delete [] etalon;
		delete [] sorting;	
	};
	out<<endl;
}