By GokiSoft.com| 20:10 20/09/2023|
Lập Trình C

Bài tập ôn luyện mảng 1 chiều - Lập trình C

Bài 1 : Nhập vào mảng gồm N số nguyên - In ra danh sách ngược của mảng đó

Ví du : mảng nhập vào là : 1, 2, 3, 4, 5, 6 -> In ra kết quả như sau : 6, 5, 4, 3, 2, 1

Bài 2 : Nhập vào mảng gồm N số nguyện -> Thực hiện hoán đổi ngược lại vị tri của mang

ví du : mảng a gồm các phần tử 1, 2, 3, 4, 5, 6 -> yêu cầu chuyển đổi để mảng a chưa danh sách ngược : 6, 5, 4, 3, 2, 1

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Nguyễn Xuân Mai [T2008A]
Nguyễn Xuân Mai

2020-09-17 03:47:16



#include <stdio.h>
#include <stdlib.h>


/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	int i,n;
	printf("\nNhap so nguyen N:");
	scanf("%d",&n);
	int t[n];
	for(i=0;i<=n-1;i++){
		printf("\nNhap t[%d]:",i);
		scanf("%d",&t[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d ",t[i]);
	}
	return 0;
}



nguyễn Sử [T2008A]
nguyễn Sử

2020-09-17 03:46:40



int main(int argc, char *argv[]) {
int i = 0, n, t;
		printf("\nNhap n: ");
		scanf("%d, &n");
		int a[n];
	for(i = 1; i < n; i++){
		
		printf("\nNhap n[%d]: ", i);
		scanf("%d, &a[i]");
}		
	for(i = n -1; i >= 0; i--){
	printf("%d",a[i]);
	scanf("%d", &a[i]);
	
}

	return 0;
	
}
	




vuong huu phu [T2008A]
vuong huu phu

2020-09-17 03:25:01



#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
int n,i,t;
t=0;
i=0;
printf("\n nhap n = ");
scanf("%d",&n);
int a [n];

for(i=0;i<n;i++){
	printf("\n nhap a[%d]",i);
    scanf("%d",&a[i]);
	}
	for(i = n -1; i >= 0; i--){
	printf("%d",a[i]);}
	return 0;
}




Trần Văn Lâm [T2008A]
Trần Văn Lâm

2020-09-17 02:28:47



#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	//BAI 1
	int n;
	printf("\nNhap so n:");
	scanf("%d", &n);
	int h[n], i;
	
	for(i = 0; i < n; i++){
		printf("\nNhap h[%d]:", i);
		scanf("%d", &h[i]);
	}
	for(i = n -1; i >= 0; i--){
		printf("\nNhap h[%d]:", i);
		scanf("%d", &h[i]);
	}
	
	
	return 0;