filenames and namespace fixes

This commit is contained in:
Krishna Vedala
2020-05-25 23:22:26 -04:00
parent 120fe06fcb
commit 82dab7515c
5 changed files with 10 additions and 11 deletions

View File

@@ -2,13 +2,12 @@
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
// Declaring variables for maintaing prime numbers and to check whether a number
// is prime or not
bool isprime[1000006];
vector<int> prime_numbers;
vector<pair<int, int>> factors;
std::vector<int> prime_numbers;
std::vector<std::pair<int, int>> 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;

View File

@@ -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;
}

View File

@@ -9,7 +9,6 @@
#include <cstdio>
#include <iostream>
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;
}