Hello im new to the programing world im still in school and just finished a python class and starting tomorrow will be in a c++ class so to just mess around before class ive been trying to convert one of my programs from python to c++
here is the python:
Code:
import random as R
def array(size, initial=0):
return [initial for i in range(size)]
def randint():
count = 0
flag = 0
rannum = array(100, 0) # Build an array with 1000 spaces
while count != 100: # Loop and fill the array with 1-52 in random order
rannum[count] = R.randint(1, 500)
count += 1
print(rannum)
print('count', count)
while flag == 0:
flag = 1
k = 0
while k <= (count - 2):
if rannum[k] < rannum[k + 1]:
temp = rannum[k]
rannum[k] = rannum[k + 1]
rannum[k + 1] = temp
flag = 0
k += 1
print('Sorted List......')
k = 0
while k <= (count - 1):
print (rannum[k])
k += 1
randint()
Here is the c++ ive been working on:
Code:
//---------------------------------------------------------------------------
#include <iostream>
#include <tchar.h>
#include <time.h>
//---------------------------------------------------------------------------
// School.cpp : Defines the entry point for the console application.
//
using namespace std;
int main()
{
int rannum[100];
int count;
int k;
int temp;
int lowest=1, highest=100;
int range=(highest-lowest)+1;
int flag;
int blank;
srand((unsigned)time(0));
count;
while (count != 100) {
rannum[count] = lowest+int(range*rand()/(RAND_MAX + 1.0));
count++;
//cout << rannum;
//cout << " count " << count << endl;
// cin >> blank;
}
while (flag == 0)
{
flag = 1;
k = 0;
while (k <= (count - 2))
{
if (rannum[k] < rannum[k + 1]) {
temp = rannum[k];
rannum[k] = rannum[k + 1];
rannum[k + 1] = temp;
flag = 0;
k++;
}
}
cout << "Sorted List";
k = 0;
while (k <= (count - 1))
{
cout << rannum[k];
k++;
}
}
cout << "pause";
cin >> blank;
return 0;
}
can anyone give me some pointers