Hi everyone,
I'm new to this site and programming, and i was wondering if i could get some help with a programming problem of mine.
I have to print 10000 random numbers ranging from 0 to 10000.
The numbers should be put in the console screen and a txt. file.
I have these two steps done, but then i don't know what to do afterward.
The program should then read each number from the file and check to see if it is palindromic.
Then the program should count the number of palindromic numbers in the txt. file, and create a new txt. file containing only the palindromic numbers.
Then the palindromic numbers should be displayed in the console window along with the number of palindromic numbers there are.
//This is the code i have so far
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
const int arraysize = 10000;
int numbers[arraysize];
int i;
void CreateArray();
void DisplayArray();
int main()
{
CreateArray();
DisplayArray();
system("Pause");
}
void CreateArray()
// Creates the inital random number array
{
srand( (unsigned int )time(0) );
for (i=0;i<arraysize;i++)
{
numbers[i] = rand() % 10000;
}
}
void DisplayArray()
// displays the array in the console window
{
int i;
for (i=0;i<arraysize;i++)
{
cout << numbers[i] << endl;
}
// displays the array in the txt. file
ofstream marksoutput;
marksoutput.open("C:/Users/Bart/Desktop/RandomNumbers.txt");
for (i=0;i<arraysize;i++)
{
marksoutput << numbers[i] << endl;
}
marksoutput.close();
}