Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // W0292378_A6.cpp
- // Program created by
- // Student ID#
- // Assignment #7 - Headers and Source Files
- //
- // Program Description: This program
- #include "stdafx.h"
- #include <stdlib.h>
- #include <ctype.h>
- #include <time.h>
- #define num_of_elements 10
- void genArr();
- //int * arrSort(int* a);
- void main()
- {
- int i;
- int randArray[num_of_elements];
- genArr(randArray);
- printf("The contents of this array are: \n");
- for (i = 0; i < num_of_elements; i++) {
- printf("randArray[%d]: %d\n", i, *(randArray + i));
- }
- //printf("The sorted contents of the array are: \n");
- //arrSort(randArray);
- //for (i = 0; i < num_of_elements; i++) {
- // printf("randArray[%d]: %d\n", i, *(randArray + i));
- //}
- system("pause");
- }
- void genArr(int * a) {
- int i;
- time_t t;
- srand((unsigned)time(&t));
- for (i = 0; i < num_of_elements; i++) {
- a[i] = rand() % 51;
- }
- return;
- }
- //int* arrSort(int* a){
- // int i, j;
- //
- // for (int i = 0; i < num_of_elements; i++) {
- //
- // for (j = 0; j < num_of_elements; j++) {
- //
- // if (*(a + j) > *(a + i))
- // {
- // int tmp = *(a + i); //Using temporary variable for storing last value
- // *(a + i) = *(a + j); //replacing value
- // *(a + j) = tmp;
- // }
- // }
- // return a;
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement