Created
May 21, 2018 12:40
-
-
Save frzleaf/0320d5cc06420bbfe76a8da70c297310 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)); | |
} | |
} | |
void xoaphantuchan(int *mang, int soluong){ | |
int i = 1; | |
int j = 1; | |
int chanlonnhat = *mang; | |
for (; i < soluong; i++){ | |
int so = * (i + mang); | |
if(so % 2 == 0 && (so > chanlonnhat || chanlonnhat % 2 == 1)){ | |
chanlonnhat = so; | |
j = i; | |
} | |
} | |
if(chanlonnhat % 2 == 0){ | |
for ( ; j < soluong - 1; j++){ | |
*(mang + j) = *(mang + j + 1); | |
} | |
} else { | |
printf("Mang khong co so chan"); | |
return; | |
} | |
} | |
int main(){ | |
printf("Nhap so phan tu, sau do nhap mang: \n"); | |
int soluong; | |
scanf("%d", &soluong); | |
int *mang = taomang(soluong); | |
xoaphantuchan(mang, soluong); | |
inmang(mang, soluong - 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment