C++ 以c+形式排队+;向前推
代码是codeforces中一个问题的答案,所以我只需要代码中的编程错误是什么..队列出了问题,他没有推送元素,或者可能是输出中的问题..你能帮我吗 当我运行它时,他们会打印一个随机数,而不是我将其放入队列中的数字C++ 以c+形式排队+;向前推,c++,stl,queue,C++,Stl,Queue,代码是codeforces中一个问题的答案,所以我只需要代码中的编程错误是什么..队列出了问题,他没有推送元素,或者可能是输出中的问题..你能帮我吗 当我运行它时,他们会打印一个随机数,而不是我将其放入队列中的数字 #include<bits/stdc++.h> using namespace std; bool check(int a , int b , string s){ int test[a][b]; int k = 0; for(int i =
#include<bits/stdc++.h>
using namespace std;
bool check(int a , int b , string s){
int test[a][b];
int k = 0;
for(int i = 0 ; i < b ; ++i){
for(int j = 0 ; j < a ; ++j){
test[i][j] = s[k++];
}
}
bool f = true;
bool fx = false;
for(int i = 0 ; i < b ; ++i){
for(int j = 0 ; j < a ; ++j){
if(test[j][i] == 'O'){
f = false;
break;
}
}
if(f){
fx = true;
break;
}
f = true;
}
return fx;
}
int main(void){
int t;
cin>>t;
string s;
queue<int> qa;
queue<int> qb;
const int n = 12;
for(int i = 0 ; i < t ; ++i){
cin>>s;
int cnt = 0;
int a[6] = {1 , 2 , 3 ,4 ,6 , 12};
int b[6] = {12 , 6 , 4 , 3 ,2 , 1};
for(int j = 0 ; j < 6 ; ++j){
if(check(a[j] , b[j] , s)){
++cnt;
qa.push(a[j]);
qb.push(b[j]);
}
}
cout<<cnt<<' ';
while(!qa.empty() && !qb.empty()){
cout<<qa.front() <<'x'<<qb.front()<<' ';
qa.pop();
qb.pop();
}
cout<<endl;
}
}
#包括
使用名称空间std;
布尔检查(整数a、整数b、字符串s){
智力测验[a][b];
int k=0;
对于(int i=0;i>t;
字符串s;
队列质量保证;
队列qb;
常数int n=12;
对于(int i=0;i>s;
int-cnt=0;
inta[6]={1,2,3,4,6,12};
int b[6]={12,6,4,3,2,1};
对于(int j=0;j<6;++j){
如果(勾选(a[j],b[j],s)){
++碳纳米管;
推(a[j]);
qb.推(b[j]);
}
}
在这一部分中不能
int test[a][b];
int k = 0;
for(int i = 0 ; i < b ; ++i)
{
for(int j = 0 ; j < a ; ++j)
{
test[i][j] = s[k++];
}
}
int测试[a][b];
int k=0;
对于(int i=0;i
您创建了测试[a][b],但在测试[b][a]之前一直可以访问。您是否使用了调试器?它有什么问题?您希望得到什么输出?您得到什么输出?请不要#包括它的非标准“int main(void)”在C++中,这是很有意义的,C++中不是这样。你输入什么?除非输入至少十二个字符,否则程序是未定义的,可以输出任何东西(或者没有任何东西)。
相当于任何函数的f()
,包括main函数