diff --git a/computer_oriented_statistical_methods/Secant_method.CPP b/computer_oriented_statistical_methods/secant_method.cpp similarity index 100% rename from computer_oriented_statistical_methods/Secant_method.CPP rename to computer_oriented_statistical_methods/secant_method.cpp diff --git a/computer_oriented_statistical_methods/successive_approximation.CPP b/computer_oriented_statistical_methods/successive_approximation.cpp similarity index 100% rename from computer_oriented_statistical_methods/successive_approximation.CPP rename to computer_oriented_statistical_methods/successive_approximation.cpp diff --git a/math/prime_factorization.cpp b/math/prime_factorization.cpp index bd1b99d97..c018de666 100644 --- a/math/prime_factorization.cpp +++ b/math/prime_factorization.cpp @@ -2,13 +2,12 @@ #include #include #include -using namespace std; // Declaring variables for maintaing prime numbers and to check whether a number // is prime or not bool isprime[1000006]; -vector prime_numbers; -vector> factors; +std::vector prime_numbers; +std::vector> factors; // Calculating prime number upto a given range void SieveOfEratosthenes(int N) { @@ -43,7 +42,7 @@ void prime_factorization(int num) { number = number / prime_numbers[i]; } - if (count) factors.push_back(make_pair(prime_numbers[i], count)); + if (count) factors.push_back(std::make_pair(prime_numbers[i], count)); } } @@ -52,9 +51,9 @@ void prime_factorization(int num) { */ int main() { int num; - cout << "\t\tComputes the prime factorization\n\n"; - cout << "Type in a number: "; - cin >> num; + std::cout << "\t\tComputes the prime factorization\n\n"; + std::cout << "Type in a number: "; + std::cin >> num; SieveOfEratosthenes(num); @@ -62,7 +61,7 @@ int main() { // Prime factors with their powers in the given number in new line for (auto it : factors) { - cout << it.first << " " << it.second << endl; + std::cout << it.first << " " << it.second << std::endl; } return 0; diff --git a/others/GCD_of_n_numbers.cpp b/others/GCD_of_n_numbers.cpp index b592e5931..37e82173a 100644 --- a/others/GCD_of_n_numbers.cpp +++ b/others/GCD_of_n_numbers.cpp @@ -5,7 +5,7 @@ int main() { int n; std::cout << "Enter value of n:" << std::endl; std::cin >> n; - int a[n]; + int *a = new int[n]; int i, j, gcd; std::cout << "Enter the n numbers:" << std::endl; for (i = 0; i < n; i++) std::cin >> a[i]; @@ -18,5 +18,6 @@ int main() { gcd = a[j] % gcd; // calculating GCD by division method } std::cout << "GCD of entered n numbers:" << gcd; + delete[] a; return 0; } diff --git a/others/fibonacci_fast.cpp b/others/fibonacci_fast.cpp index dd3481422..381a82d7c 100644 --- a/others/fibonacci_fast.cpp +++ b/others/fibonacci_fast.cpp @@ -9,7 +9,6 @@ #include #include -using namespace std; const long long MAX = 93; @@ -31,7 +30,7 @@ long long fib(long long n) { int main() { // Main Function for (long long i = 1; i < 93; i++) { - cout << i << " th fibonacci number is " << fib(i) << "\n"; + std::cout << i << " th fibonacci number is " << fib(i) << "\n"; } return 0; }