Skip to content

Commit 62ff5e5

Browse files
authored
Indent code
1 parent 68c93d8 commit 62ff5e5

File tree

1 file changed

+70
-70
lines changed

1 file changed

+70
-70
lines changed
Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,86 @@
1-
#include <iostream>
2-
using namespace std;
1+
#include <iostream>
2+
using namespace std;
33

4-
// Maximum number of digits in output
4+
// Maximum number of digits in output
55
// x^n where 1 <= x, n <= 10000 and overflow may happen
6-
#define MAX 100000
6+
#define MAX 100000
77

8-
// This function multiplies x
9-
// with the number represented by res[].
10-
// res_size is size of res[] or
11-
// number of digits in the number
12-
// represented by res[]. This function
13-
// uses simple school mathematics
14-
// for multiplication.
15-
// This function may value of res_size
16-
// and returns the new value of res_size
17-
int multiply(int x, int res[], int res_size) {
8+
// This function multiplies x
9+
// with the number represented by res[].
10+
// res_size is size of res[] or
11+
// number of digits in the number
12+
// represented by res[]. This function
13+
// uses simple school mathematics
14+
// for multiplication.
15+
// This function may value of res_size
16+
// and returns the new value of res_size
17+
int multiply(int x, int res[], int res_size) {
1818

19-
// Initialize carry
20-
int carry = 0;
19+
// Initialize carry
20+
int carry = 0;
2121

22-
// One by one multiply n with
23-
// individual digits of res[]
24-
for (int i = 0; i < res_size; i++) {
25-
int prod = res[i] * x + carry;
22+
// One by one multiply n with
23+
// individual digits of res[]
24+
for (int i = 0; i < res_size; i++) {
25+
int prod = res[i] * x + carry;
2626

27-
// Store last digit of
28-
// 'prod' in res[]
29-
res[i] = prod % 10;
27+
// Store last digit of
28+
// 'prod' in res[]
29+
res[i] = prod % 10;
3030

31-
// Put rest in carry
32-
carry = prod / 10;
33-
}
31+
// Put rest in carry
32+
carry = prod / 10;
33+
}
3434

35-
// Put carry in res and
36-
// increase result size
37-
while (carry) {
38-
res[res_size] = carry % 10;
39-
carry = carry / 10;
40-
res_size++;
41-
}
42-
return res_size;
43-
}
35+
// Put carry in res and
36+
// increase result size
37+
while (carry) {
38+
res[res_size] = carry % 10;
39+
carry = carry / 10;
40+
res_size++;
41+
}
42+
return res_size;
43+
}
4444

45-
// This function finds
46-
// power of a number x
47-
void power(int x, int n)
48-
{
45+
// This function finds
46+
// power of a number x
47+
void power(int x, int n)
48+
{
4949

50-
//printing value "1" for power = 0
51-
if(n == 0 ){
52-
cout<<"1";
53-
return;
54-
}
50+
//printing value "1" for power = 0
51+
if(n == 0 ){
52+
cout<<"1";
53+
return;
54+
}
5555

5656

57-
int res[MAX];
58-
int res_size = 0;
59-
int temp = x;
57+
int res[MAX];
58+
int res_size = 0;
59+
int temp = x;
6060

61-
// Initialize result
62-
while (temp != 0) {
63-
res[res_size++] = temp % 10;
64-
temp = temp / 10;
65-
}
61+
// Initialize result
62+
while (temp != 0) {
63+
res[res_size++] = temp % 10;
64+
temp = temp / 10;
65+
}
6666

67-
// Multiply x n times
68-
// (x^n = x*x*x....n times)
69-
for (int i = 2; i <= n; i++)
70-
res_size = multiply(x, res, res_size);
67+
// Multiply x n times
68+
// (x^n = x*x*x....n times)
69+
for (int i = 2; i <= n; i++)
70+
res_size = multiply(x, res, res_size);
7171

72-
cout << x << "^" << n << " = ";
73-
for (int i = res_size - 1; i >= 0; i--)
74-
cout << res[i];
75-
}
72+
cout << x << "^" << n << " = ";
73+
for (int i = res_size - 1; i >= 0; i--)
74+
cout << res[i];
75+
}
7676

77-
// Driver program
78-
int main() {
79-
int exponent, base;
80-
printf("Enter base ");
81-
scanf("%id \n", &base);
82-
printf("Enter exponent ");
83-
scanf("%id", &exponent);
84-
power(base, exponent);
85-
return 0;
86-
}
77+
// Driver program
78+
int main() {
79+
int exponent, base;
80+
printf("Enter base ");
81+
scanf("%id \n", &base);
82+
printf("Enter exponent ");
83+
scanf("%id", &exponent);
84+
power(base, exponent);
85+
return 0;
86+
}

0 commit comments

Comments
 (0)