[C++]uva729总是wa的看这里
如果你总是WA而又不知道哪里出了问题,那么你一定是输出时没有判断是否是最后一次循环,如果是最后一个test case则不要输出空格行!!
#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>using namespace std;int main(){int cases;cin>>cases;char ch=getchar();while (cases--){char black[10];cin.getline(black,10);int N,H;cin>>N>>H;char str[20];memset(str,'0',N);str[N]='\0';for (int i=0;i<H;i++){str[N-1-i]='1';}do{for (int i=0;i<N;i++)cout<<str[i];cout<<endl;}while(next_permutation(str,str+N));if (cases) cout<<endl;}return 0;}