-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathbujor.cpp
43 lines (42 loc) · 882 Bytes
/
bujor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# include <fstream>
# include <algorithm>
# include <iomanip>
# define NR 205
using namespace std;
ifstream f("bujor.in");
ofstream g("bujor.out");
int i,j,n,m,o,t;
int a[NR][NR];
double p[NR][NR];
int main ()
{
f>>t;
for (o=1; o<=t; ++o)
{
f>>n;
for (i=1; i<=n; ++i)
for (j=1; j<=n; ++j)
{
f>>a[i][j];
p[i][j]=0;
}
for (i=1; i<=n; ++i)
{
for (j=1; j<=n; ++j)
{
if (a[i][j])//daca joaca la masinuta j
{
p[j][i]=((double)1)/((double)a[i][j]);
break;
}
}
}
for (i=1; i<=n; ++i)
{
for (j=1; j<=n; ++j)
g<<fixed<<setprecision(9)<<p[i][j]<<" ";
g<<"\n";
}
}
return 0;
}