| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我wa了N久,最后写个随机数生成器,再找个ac代码,才把bug找出来。。。In Reply To:谁能告诉这段代码为什么错了?自己运动结果正常,为什么submit就wrong result呢 Posted by:zhuyunxiang1984 at 2011-02-03 23:46:42 //get random numbers
#include <iostream>
#include <ctime>
#include <fstream>
#include <cstdlib>
using namespace std;
int main()
{
int i, j;
int r, c;
ofstream f("rand_num.txt", ios::out | ios::trunc);
if(!f.is_open())
{
cout << "Can not open file!\n";
return 1;
}
srand(time(NULL));
r = rand() % 10 + 1;
c = rand() % 10 + 1;
f << r << ' ' << c << endl;
for(i = 0; i < r; ++i)
{
for(j = 0; j < c; ++j)
f << rand() % 100 << ' ';
f << endl;
}
f.close();
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator