-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab8b4.c
More file actions
38 lines (33 loc) · 740 Bytes
/
Copy pathlab8b4.c
File metadata and controls
38 lines (33 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<stdio.h>
#include<stdlib.h>
int main()
{
int n;
printf("nhap so nguyen bat ky:");
scanf("%d",&n);
if(n<=0)
{
printf("nhap lai so nguyen duong: \n");
scanf("%d", &n);
}
float *a = (float *)malloc(n*sizeof(float));
if (a == NULL)
{
printf("khong du bo nho cap phat.\n");
return 1;
}
printf("nhap du lieu cho mang so thuc:\n",n);
for(int i=0;i<n;i++)
{
printf("nhap phan tu thu [%d] cua mang: ",i);
scanf("%f",&a[i]);
}
printf("mang so thuc sau khi nhap: ");
for(int i=0;i<n;i++)
{
printf("%.2f ",a[i]);
}
printf("\n");
free(a);
return 0;
}