没输出
#include <iostream>using namespace std;
char a;
int yu;
int ans;
int n, m;
bool checkk(int x, int y){
return yu == (ans + ans + ans + ans + ans + ans + ans + ans + ans);
}
bool check(int x, int y){
for(int i=1;i<=x-2;i++){
for(int j=1;j<=m;j++){
if(yu == -1)
continue;
else if(!checkk(i, j)){
return false;
}
}
}
if(x >= 2){
for(int i=1;i<=m-2;i++){
if(yu == -1){
continue;
}
else if(!checkk(x-1, i)){
return false;
}
}
}
return true;
}
void dfs(int x, int y){
if(x == n+1){
if(check(x, y)){
for(int i=n-1;i<=n;i++){
for(int j=1;j<=m;j++){
if(yu == -1){
continue;
}
else if(!checkk(i, j)){
return;
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cout << ans;
}
cout << endl;
}
return;
}
}
if(!check(x, y)){
return;
}
ans = 0;
if(y < m){
dfs(x, y+1);
}
else{
dfs(x+1, 1);
}
ans = 1;
if(y < m){
dfs(x, y+1);
}
else{
dfs(x+1, 1);
}
ans = a - '0';
}
int main(){
cin >> n >> m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >> a;
if(a == '_'){
yu = -1;
}
else{
yu = a - '0';
}
}
}
dfs(1, 1);
return 0;
}
你的代码可能有一些问题,导致没有输出结果。首先,你的代码缺少主函数的定义,应该添加一个主函数来运行你的代码。其次,你的代码中使用了两个函数`checkk`和`check`,但是这两个函数没有被调用,所以也没有输出结果。
以下是修改后的代码:
#include <iostream>
using namespace std;
bool checkk(int x, int y){
return (x + y) % 9 == 0;
}
bool check(int x, int y){
for (int i = 1; i <= y; i++){
if (checkk(x, i)){
return true;
}
}
return false;
}
int main(){
int n, m;
cin >> n >> m;
if (check(n, m)){
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
在主函数中,我们首先读取两个整数n和m,并将它们作为参数传递给函数`check`。然后,我们根据`check`函数的返回值来输出结果。
运行代码,输入两个整数,程序会根据输入的值判断结果并输出。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
页:
[1]