NeZox's blog

By NeZox, history, 5 months ago, In Russian,

Please help me, I want to create generator for 20 test and save them to different files. How I can do this ?

 
 
 
 

»
5 months ago, # |
  Vote: I like it +5 Vote: I do not like it
int main () {
   FILE *f, *ff;
   srand(259);
   for (int i = 1; i <= 20; ++i) {  
       string s = "";
       int x = i;
       while (x)
           s = char(x % 10 + '0') + s, x /= 10;
       f = fopen(s.c_str(), "w");
       int test = Rand();
       fprintf(f, "%d", test);
       fclose(f);
       int answer = bla_bla;
       s = s + ".a";
       ff = fopen(s.c_str(), "w");
       fprintf(ff, "%d", answer);
       fclose(ff);
   }
   return 0;
}