

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int count[13] = {0};
int dice1, dice2, sum;
srand(time(NULL));
for (int i = 0; i < 100; i++) {
dice1 = rand() % 6 + 1; // số từ 1-6
dice2 = rand() % 6 + 1; // số từ 1-6
sum = dice1 + dice2;
count[sum]++;
}
printf("Thong ke so lan xuat hien cua tong diem:\n");
for (int i = 2; i <= 12; i++) {
printf("Tong %d: %d lan\n", i, count[i]);
}
return 0;
}
`\color{#7B2FF7}Z\color{#8E44F7}e\color{#A55CF6}l\color{#BB74F5}y\color{#D08CF4}t\color{#E6A4F3}h`
Hãy giúp mọi người biết câu trả lời này thế nào?
#include <stdio.h>
int a[10], b[10], c[10], n;
void nhap() {
int i;
printf("Nhap n: ");
scanf("%d", &n);
if (n > 0 && n <= 10) {
printf("Nhap %d so: ", n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
}
}
void tach() {
int i, j = 0, k = 0;
for (i = 0; i < n; i++) {
if (a[i] > 0) {
b[j] = a[i];
j++;
} else if (a[i] < 0) {
c[k] = a[i];
k++;
}
}
printf("Mang b: ");
for (i = 0; i < j; i++) {
printf("%d ", b[i]);
}
printf("\nMang c: ");
for (i = 0; i < k; i++) {
printf("%d ", c[i]);
}
}
int main() {
nhap();
if (n > 0 && n <= 10)
tach();
else
printf("n khong hop le");
return 0;
}Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin