Skip to content

Instantly share code, notes, and snippets.

@frzleaf
Created May 21, 2018 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frzleaf/0320d5cc06420bbfe76a8da70c297310 to your computer and use it in GitHub Desktop.
Save frzleaf/0320d5cc06420bbfe76a8da70c297310 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));
}
}
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