дороботайте код пожалуйста

Jurijus
Дата: 07.11.2014 19:09:06
последние части лятят слишком долго как сними быть.

#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include<fstream> 
#include <windows.h>
#include <string>
#include <ctime>  
#include <stdio.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <iostream> 
#include <time.h>
using namespace std;

  class z//nekotorii nabor svoist polei kotorie potrozdelitsia polia i metodi
{
public://publichnie i zashenie
	char maska[256];
	char buffer[271];
    char buffer2[9];
    char buffer3[2];
	 string bin;
	  	
	};

   int main()
{ 
 FreeConsole();
   z a;
	z b;
	z c;
	z d;
	z e;
	z l;
int xc=0;
int ck=0,jk, gh=0,cv,ui;
	char s3[999000];
       
//char holder=' ';

 long t1 = clock();

ifstream filesgk( "yourfile.txt" );
filesgk>>a.maska;



 ifstream filer(a.maska);
   while (!filer.eof())
           {

		    fill_n( e.buffer2, 9, '\0' );	
  filer.read( e.buffer2,8);//nazvanie "file" v chitke zabisit
  		 string sgl(e.buffer2);

				  fill_n( e.buffer3, 2, '\0' );	
  filer.read( e.buffer3,1);//nazvanie "file" v chitke zabisit
  		 string sgc(e.buffer3);
		   ck=ck+1;
		   jk=ck/999000;
		   jk=jk-1;
		   ui=jk*999000;
		   cv=ck-ui;
		 }

 ifstream file(a.maska);
   while (!file.eof())
           {	
	
	  
 fill_n( a.buffer, 271, '\0' );	
  file.read( a.buffer,270);//nazvanie "file" v chitke zabisit
  		 string sg(a.buffer);

		  fill_n( b.buffer, 271, '\0' );	
  file.read( b.buffer,270);//nazvanie "file" v chitke zabisit
  		 string sgi(b.buffer);

			     fill_n( c.buffer, 271, '\0' );	
  file.read( c.buffer,270);//nazvanie "file" v chitke zabisit
  		 string sgiw(b.buffer);

				   fill_n( d.buffer, 271, '\0' );	
  file.read( d.buffer,270);//nazvanie "file" v chitke zabisit
  		 string sgig(d.buffer);

				   xc=xc+1;
				

				    if(xc<=1700)
			   {

			strcpy(s3,a.buffer);
			strcat(s3,b.buffer);
			strcat(s3,c.buffer);
            strcat(s3,d.buffer);

					}
			  

			if(xc==1700)
			   {
         		a.bin=a.bin+s3;

		      xc=0;
			  fill_n( s3, 999000, '\0' );
			  gh=gh+1;
			   }
			 
			  if(gh>=jk)
			  {
	



				 if(sizeof(s3)==999000)
				 {
				   	a.bin=a.bin+s3;

				 }
			

				  
			  }



//raboti s blokom



   }
 file.close();



 
      		      ofstream save15("numberts.txt",ios::out);
{

save15<<a.bin;


}
save15.close();



ofstream binaryeikilif("numberblockend.txt");
{
binaryeikilif<<"*";
	}
binaryeikilif.close();

long t2 = clock();

    cout << "Done!" << endl; 
    cout << "Time: " << (t2 - t1)/1000/60 << " minut."<< endl;
    cout << "Time: " << (t2 - t1)/1000<< " seconds."<< endl;
    cout << "Time: " << (t2 - t1) << " millisends."<< endl;


	ofstream binaryeikilisss("time.txt");
{ 
	    binaryeikilisss<< (t2 - t1)/1000/60 << " minut."<< endl;
        binaryeikilisss<< (t2 - t1)/1000 << " seconds."<< endl;
        binaryeikilisss << "Time: " << (t2 - t1) << " millisends."<< endl;
	}
binaryeikilisss.close(); 

return 0;
}
mayton
Дата: 07.11.2014 22:44:10
Задание как-то не чётко обозначено.
Jurijus
Дата: 08.11.2014 18:04:53
как сделать чтобы первый код роботал быстро как первый.
#include<fstream> 
#include <windows.h>
#include <string>
#include <iostream> 
#include <time.h>
using namespace std;
int main()
{
FreeConsole();
char buffer[9];
char maska[8];
string bin;
string bin2;
 long t1 = clock();
ifstream filesgk( "yourfile.txt" );
filesgk>>maska;
 ifstream file(maska);
   while (!file.eof())
           {	  
 fill_n( buffer, 9, '\0' );	
  file.read( buffer,8);//nazvanie "file" v chitke zabisit
  string s(buffer);
 	bin=bin+buffer;
   }
 
 file.close();
   	  ofstream save15("numberts.txt",ios::out);
{

save15<<bin;

}
save15.close();
ofstream binaryeikilif("numberblockend.txt");
{
binaryeikilif<<"*";
	}
binaryeikilif.close();

long t2 = clock();

    cout << "Done!" << endl; 
    cout << "Time: " << (t2 - t1)/1000/60 << " minut."<< endl;
    cout << "Time: " << (t2 - t1)/1000<< " seconds."<< endl;
    cout << "Time: " << (t2 - t1) << " millisends."<< endl;


	ofstream binaryeikilisss("time.txt");
{ 
	    binaryeikilisss<< (t2 - t1)/1000/60 << " minut."<< endl;
        binaryeikilisss<< (t2 - t1)/1000 << " seconds."<< endl;
        binaryeikilisss << "Time: " << (t2 - t1) << " millisends."<< endl;
	}
binaryeikilisss.close(); 

return 0;
}

#include<fstream> 
#include <windows.h>
#include <string>
#include <iostream> 
#include <time.h>
using namespace std;
int main()
{
FreeConsole();
char buffer[999001];
char maska[256];
string bin;
string bin2;
 long t1 = clock();
ifstream filesgk( "yourfile.txt" );
filesgk>>maska;
 ifstream file(maska);
   while (!file.eof())
           {	  
 fill_n( buffer, 999001, '\0' );	
  file.read( buffer,999000);//nazvanie "file" v chitke zabisit
  string s(buffer);
 	bin=bin+buffer;
   }
 
 file.close();
   	  ofstream save15("numberts.txt",ios::out);
{

save15<<bin;

}
save15.close();
ofstream binaryeikilif("numberblockend.txt");
{
binaryeikilif<<"*";
	}
binaryeikilif.close();

long t2 = clock();

    cout << "Done!" << endl; 
    cout << "Time: " << (t2 - t1)/1000/60 << " minut."<< endl;
    cout << "Time: " << (t2 - t1)/1000<< " seconds."<< endl;
    cout << "Time: " << (t2 - t1) << " millisends."<< endl;


	ofstream binaryeikilisss("time.txt");
{ 
	    binaryeikilisss<< (t2 - t1)/1000/60 << " minut."<< endl;
        binaryeikilisss<< (t2 - t1)/1000 << " seconds."<< endl;
        binaryeikilisss << "Time: " << (t2 - t1) << " millisends."<< endl;
	}
binaryeikilisss.close(); 

return 0;
}
Jurijus
Дата: 08.11.2014 18:06:46
Jurijus
как сделать чтобы первый код роботал быстро как второй.
#include<fstream> 
#include <windows.h>
#include <string>
#include <iostream> 
#include <time.h>
using namespace std;
int main()
{
FreeConsole();
char buffer[9];
char maska[8];
string bin;
string bin2;
 long t1 = clock();
ifstream filesgk( "yourfile.txt" );
filesgk>>maska;
 ifstream file(maska);
   while (!file.eof())
           {	  
 fill_n( buffer, 9, '\0' );	
  file.read( buffer,8);//nazvanie "file" v chitke zabisit
  string s(buffer);
 	bin=bin+buffer;
   }
 
 file.close();
   	  ofstream save15("numberts.txt",ios::out);
{

save15<<bin;

}
save15.close();
ofstream binaryeikilif("numberblockend.txt");
{
binaryeikilif<<"*";
	}
binaryeikilif.close();

long t2 = clock();

    cout << "Done!" << endl; 
    cout << "Time: " << (t2 - t1)/1000/60 << " minut."<< endl;
    cout << "Time: " << (t2 - t1)/1000<< " seconds."<< endl;
    cout << "Time: " << (t2 - t1) << " millisends."<< endl;


	ofstream binaryeikilisss("time.txt");
{ 
	    binaryeikilisss<< (t2 - t1)/1000/60 << " minut."<< endl;
        binaryeikilisss<< (t2 - t1)/1000 << " seconds."<< endl;
        binaryeikilisss << "Time: " << (t2 - t1) << " millisends."<< endl;
	}
binaryeikilisss.close(); 

return 0;
}

#include<fstream> 
#include <windows.h>
#include <string>
#include <iostream> 
#include <time.h>
using namespace std;
int main()
{
FreeConsole();
char buffer[999001];
char maska[256];
string bin;
string bin2;
 long t1 = clock();
ifstream filesgk( "yourfile.txt" );
filesgk>>maska;
 ifstream file(maska);
   while (!file.eof())
           {	  
 fill_n( buffer, 999001, '\0' );	
  file.read( buffer,999000);//nazvanie "file" v chitke zabisit
  string s(buffer);
 	bin=bin+buffer;
   }
 
 file.close();
   	  ofstream save15("numberts.txt",ios::out);
{

save15<<bin;

}
save15.close();
ofstream binaryeikilif("numberblockend.txt");
{
binaryeikilif<<"*";
	}
binaryeikilif.close();

long t2 = clock();

    cout << "Done!" << endl; 
    cout << "Time: " << (t2 - t1)/1000/60 << " minut."<< endl;
    cout << "Time: " << (t2 - t1)/1000<< " seconds."<< endl;
    cout << "Time: " << (t2 - t1) << " millisends."<< endl;


	ofstream binaryeikilisss("time.txt");
{ 
	    binaryeikilisss<< (t2 - t1)/1000/60 << " minut."<< endl;
        binaryeikilisss<< (t2 - t1)/1000 << " seconds."<< endl;
        binaryeikilisss << "Time: " << (t2 - t1) << " millisends."<< endl;
	}
binaryeikilisss.close(); 

return 0;
}