You are on page 1of 1

// Sinh day ngau nhien tang trong C++ // thanhcuong.wordpress.

com #include <cstdlib> #include <iostream> #include <ctime> using namespace std; void view(int a[], int n) { cout<<"\n Day ngau nhien tang duoc sinh ra la"<<endl; for(int i = 0; i < n; i++) { cout<< a[i]<<" "; } cout<<"\n"; } int main() { int a[1000]; int n; cout<<"Nhap vao so phan tu cua day: "; cin>>n; if(n <= 0) { cout<<"So vua nhap khong hop le."; return 0; } srand(time(0)); a[0] = (rand() % 10); for(int i = 1; i < n; i++) { a[i] = a[i -1] + (rand() % 1000); } view(a,n); system("pause"); return 0; }

You might also like