Skip to content

Instantly share code, notes, and snippets.

@frzleaf
Created May 21, 2018 12:19
Show Gist options
  • Save frzleaf/107d1ddfb39961cecfd37b28e187de3f to your computer and use it in GitHub Desktop.
Save frzleaf/107d1ddfb39961cecfd37b28e187de3f to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int *taomang(soluong){
int i = 0;
int *mang = (int *) malloc(soluong * sizeof(int));
for ( ; i < soluong; ++i){
scanf("%d", (mang + i));
}
return mang;
}
int inmang(int *mang, int soluong){
int i = 0;
for ( ; i < soluong; ++i){
printf("%d\n", *(mang + i));
}
}
int channhonhat(int *mang, int soluong){
int i = 1;
int sonhonhat = *mang;
for (; i < soluong; i++){
int so = * (i + mang);
if(so % 2 == 0 && (so < sonhonhat || sonhonhat % 2 == 1)){
sonhonhat = so;
}
}
if(sonhonhat % 2 == 0){
printf("So chan nho nhat la: %d", sonhonhat);
} else {
printf("Mang khong co so chan");
}
}
int main(){
printf("Nhap so phan tu, sau do nhap mang: \n");
int soluong;
scanf("%d", &soluong);
int *mang = taomang(soluong);
channhonhat(mang, soluong);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment