Created
September 22, 2013 21:44
-
-
Save MaratB/6664159 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ctime> | |
#include <stdio.h> | |
#include <conio.h> | |
#include <stdlib.h> | |
const int N = 10; //Если float, то (float) rand() / RAND_MAX * (max - min) + min | |
main() //Если integer, то rand()%(max-min+1)+min (концы включаются), а если нет, то 1 прибавлять не надо | |
{ | |
int i, A[N],n1,n2; | |
srand(time(NULL)); //чтобы каждый раз новые числа появлялись | |
for ( i = 0; i < N; i ++ ) | |
A[i] = rand()%(21)-10; | |
printf("\nSource array:\n"); | |
n1=clock(); | |
for ( i = 0; i < N; i ++ ) | |
printf("%d ", A[i]); | |
printf("n1= %d", n1); | |
for ( i = 0; i < N; i ++ ) | |
A[i] = A[i] * 2; | |
printf("\n Result:\n"); | |
n2=clock(); | |
for ( i = 0; i < N; i ++ ) | |
printf("%d ", A[i]); | |
printf("n2= %d", n2); | |
clock(); | |
getch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment