#include <iostream>
#include <fstream>
#include <time.h>
#include <math.h>

using namespace std ;

int main() {
 int count=0;//testcast number
 double studentN;
 int i;
 long Dollar, Sent;
 double spendMoney;
 ofstream fout("testcase.txt") ;
    srand( (unsigned)time(NULL));

 while(count++ < 1000) { 
  studentN = rand()%1000;
  fout.precision(0);
  fout <<studentN<<endl;
  for(i=0;i<studentN;i++)
  {
   Dollar = ((long)rand()<<15 | rand())%1000000 ;
   Sent = rand()%100;
   spendMoney = (double)(Dollar+(double)(Sent*0.01));
   printf("$%.2d + $%.2d = $%.2f\n",Dollar,Sent,spendMoney);
   fout.precision(2);
   fout.setf(ios_base::fixed);
   fout <<spendMoney<<endl;
  }
 }
 fout<<'0'<<endl;
 cout<<'0'<<endl;

 fout.close() ;

 return 0 ;
}

저작자 표시 비영리 동일 조건 변경 허락
Posted by Lws