Created
May 21, 2018 12:19
-
-
Save frzleaf/107d1ddfb39961cecfd37b28e187de3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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