Created
June 10, 2024 14:03
-
-
Save twilightty/eace3002e55e7bc9409194489aa47f88 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> | |
#include <string.h> | |
#define MAX_NUMBERS 100 | |
int main() { | |
char input[1000]; | |
int numbers[MAX_NUMBERS]; | |
int count = 0; | |
long sum = 0; | |
long long product = 1; | |
int count_in_range = 0; | |
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, " "); | |
} | |
printf("\nSo chia het cho 3 va lon hon 10: "); | |
for (int i = 0; i < count; i++) { | |
sum += numbers[i]; | |
product *= numbers[i]; | |
if (numbers[i] > 10 && numbers[i] % 3 == 0) { | |
printf("%d ", numbers[i]); | |
} | |
if (numbers[i] >= 100 && numbers[i] <= 1000) { | |
count_in_range++; | |
} | |
} | |
printf("\n\nTong cac so: %ld", sum); | |
printf("\nTich cac so: %lld", product); | |
printf("\nCac so trong khoang [100, 1000]: %d\n", count_in_range); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment