Skip to content

Instantly share code, notes, and snippets.

@emladevops
Created June 10, 2024 14:05
Show Gist options
  • Save emladevops/0cda37b075c097fa8717af983e441409 to your computer and use it in GitHub Desktop.
Save emladevops/0cda37b075c097fa8717af983e441409 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#define MAX_NUMBERS 100
int main() {
char input[1000];
int numbers[MAX_NUMBERS];
int count = 0;
int largest_even = INT_MIN;
printf("Nhap < 100 so: \n");
fgets(input, sizeof(input), stdin);
char *token = strtok(input, " ");
while (token != NULL && count < MAX_NUMBERS) {
numbers[count] = atoi(token);
count++;
token = strtok(NULL, " ");
}
for (int i = 0; i < count; i++) {
if (numbers[i] % 2 == 0 && numbers[i] > largest_even) {
largest_even = numbers[i];
}
}
if (largest_even != INT_MIN) {
printf("\nSo chan lon nhat: %d\n", largest_even);
} else {
printf("\nKo co so chan =)))\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment