Skip to content

Commit 82dab75

Browse files
committed
filenames and namespace fixes
1 parent 120fe06 commit 82dab75

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

math/prime_factorization.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
#include <cstring>
33
#include <iostream>
44
#include <vector>
5-
using namespace std;
65

76
// Declaring variables for maintaing prime numbers and to check whether a number
87
// is prime or not
98
bool isprime[1000006];
10-
vector<int> prime_numbers;
11-
vector<pair<int, int>> factors;
9+
std::vector<int> prime_numbers;
10+
std::vector<std::pair<int, int>> factors;
1211

1312
// Calculating prime number upto a given range
1413
void SieveOfEratosthenes(int N) {
@@ -43,7 +42,7 @@ void prime_factorization(int num) {
4342
number = number / prime_numbers[i];
4443
}
4544

46-
if (count) factors.push_back(make_pair(prime_numbers[i], count));
45+
if (count) factors.push_back(std::make_pair(prime_numbers[i], count));
4746
}
4847
}
4948

@@ -52,17 +51,17 @@ void prime_factorization(int num) {
5251
*/
5352
int main() {
5453
int num;
55-
cout << "\t\tComputes the prime factorization\n\n";
56-
cout << "Type in a number: ";
57-
cin >> num;
54+
std::cout << "\t\tComputes the prime factorization\n\n";
55+
std::cout << "Type in a number: ";
56+
std::cin >> num;
5857

5958
SieveOfEratosthenes(num);
6059

6160
prime_factorization(num);
6261

6362
// Prime factors with their powers in the given number in new line
6463
for (auto it : factors) {
65-
cout << it.first << " " << it.second << endl;
64+
std::cout << it.first << " " << it.second << std::endl;
6665
}
6766

6867
return 0;

others/GCD_of_n_numbers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ int main() {
55
int n;
66
std::cout << "Enter value of n:" << std::endl;
77
std::cin >> n;
8-
int a[n];
8+
int *a = new int[n];
99
int i, j, gcd;
1010
std::cout << "Enter the n numbers:" << std::endl;
1111
for (i = 0; i < n; i++) std::cin >> a[i];
@@ -18,5 +18,6 @@ int main() {
1818
gcd = a[j] % gcd; // calculating GCD by division method
1919
}
2020
std::cout << "GCD of entered n numbers:" << gcd;
21+
delete[] a;
2122
return 0;
2223
}

others/fibonacci_fast.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <cstdio>
1111
#include <iostream>
12-
using namespace std;
1312

1413
const long long MAX = 93;
1514

@@ -31,7 +30,7 @@ long long fib(long long n) {
3130
int main() {
3231
// Main Function
3332
for (long long i = 1; i < 93; i++) {
34-
cout << i << " th fibonacci number is " << fib(i) << "\n";
33+
std::cout << i << " th fibonacci number is " << fib(i) << "\n";
3534
}
3635
return 0;
3736
}

0 commit comments

Comments
 (0)