forked from yatharthsol090/All-Codes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
q3.cpp
51 lines (43 loc) · 899 Bytes
/
q3.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
44
45
46
47
48
49
50
51
#include <iostream>
#include<math.h>
#include<fstream>
using namespace std;
int main()
{
fstream fout;
// opens an existing csv file or creates a new file.
fout.open("reportcard.csv", ios::out | ios::app);
int i, roll, phy, chem, math, bio;
string name;
int number_of_bottles ;
int number_of_prisoners ;
cin>>number_of_bottles ;
cin>>number_of_prisoners ;
int x1 =2;
for(int i=1;;i++)
{
if(pow(i,number_of_prisoners)>number_of_bottles)
{
x1=i ;
break ;
}
}
cout<<x1<<'\n' ;
// cout<<pow(2,0)<<'\n' ;
for(int i=0;i<4;i++)
{
int z=0 ;
int z2=pow(x1,i) ;
while(z<=number_of_bottles)
{
int m=z2 ;
while(m)
{
fout<<z<<',' ;
z++ ;
m--;
}
z+=z2 ;
}
fout<<'\n' ;
}