#include <iostream> using namespace std; int main() { int count = 0; for (int x = 1; x <= 3; x++) { for (int y = 1; y <= 3; y++) { for (int z = 1; z <= 3; z++) { if (5 * x + 4 * y - z == 10) { cout << “(” << x << ", " << y << ", " << z << “)” << endl; count++; } } } } cout << "Total number of solutions: " << count << endl; return 0; }改为C语言
时间: 2024-02-03 08:03:04 浏览: 70
使用include <iostream>时一定要加using namespace std
#include <stdio.h>
int main() {
int count = 0;
for (int x = 1; x <= 3; x++) {
for (int y = 1; y <= 3; y++) {
for (int z = 1; z <= 3; z++) {
if (5 * x + 4 * y - z == 10) {
printf("(%d, %d, %d)\n", x, y, z);
count++;
}
}
}
}
printf("Total number of solutions: %d\n", count);
return 0;
}
阅读全文