The contents of the input into the text, the file is read, saved to a file output, the computing program running time (c ++)

Outputs the data to a file

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<cstdlib>
#include<fstream>
#include<time.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
const LL INF=1e9+7;
const int maxn=1e5+50;
int a[maxn],b[maxn];//Deposit number has appeared and there have been several 
int main () 
{ 
    srand ((unsigned) Time ( 0 )); // ensure random function results are not the same each time ran out 
    ofstream FILEIN; //
     filein.open ( " a.txt " );
     int T; 
    T = RAND ()% . 3 + . 1 ; 
    FILEIN << T << ' \ n- ' ;
     return  0 ; 
}

Read the contents of the file, and outputs the result to a file

    freopen("input8.txt", "r",stdin);
    freopen("output8.txt", "w", stdout);

 Calculation program running time, on the beginning and end of the function main: add the header file ctime


int main ()
{ 
  Of clock_t Start, Finish;
Double totalTime; Start = Clock (); .... intermediate code that is Finish = ; Clock () totalTime = ( Double ) (Finish-Start) / ; CLOCKS_PER_SEC COUT << " run time of the program is " << << totalTime " ! s " << endl;
}

 

Guess you like

Origin www.cnblogs.com/caijiaming/p/11613076.html