Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by NguyenVietNamSon ( 5 years ago )
#include <iostream>
#include <stdlib.h>
#include <ctime>
using namespace std;

void RandomMang(float a[], int n)
{
	srand(time(0));
	// random số thực trong khoảng từ 1 đến 10
	// => random số nguyên trong khoảng từ 10 đến 100 sau đó chia 10
	for(int i = 0; i < n; ++i)
	{
		a[i] = 10 + rand() % 91; // công thức muốn random trong đoạn [x, y] => x + rand() % (y - x + 1)
		a[i] /= 10;
	}
}

void XuatMang(float a[], int n)
{
	for(int i = 0; i < n; ++i)
		cout << a[i] << endl;
}

int main()
{
	float a[100];
	int n = 5;

	RandomMang(a, n);
	XuatMang(a, n);

	system("pause");
	return 0;
}

 

Revise this Paste

Your Name: Code Language: