Debug的问题 the thread has exited with code 本帖最后由 venecy 于 2015-01-20 14:41:58 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 仅供参考//qplw.cpp#include <stdio.h>#include <string.h>#include <stdlib.h>int v=0;int w=0;int m;//记录字符串长度int n;//记录字符串中的字符种类数char map[256];//记录是哪几种字符int count[256];//记录每种字符有多少个int stack[1000];//递归用的栈,并记录当前生成的排列void Make_Map(char *str) {//统计字符串的相关信息 int s[256]; int i; memset(s,0,sizeof(s)); memset(count,0,sizeof(count)); m=strlen(str); if (w<1 || m<w) w=m; while(*str) { s[*str]++; str++; } n=0; for (i=0;i<256;i++) if (s[i]) { map[n]=i; count[n]=s[i]; n++; }}void Find(int depth) {//递归式回溯法生成全排列 if (depth==w) { int i; for (i=0;i<depth;i++) putchar(map[stack[i]]); putchar('\n'); } else { int i; if (v && depth>0) { for (i=0;i<depth;i++) putchar(map[stack[i]]); putchar('\n'); } for (i=0;i<n;i++) if (count[i]) { stack[depth]=i; count[i]--; Find(depth+1); count[i]++; } }}void main(int argc,char**argv) { if (argc<2) { printf("%s 要产生全排列的字符串 [限定长度|-1]\n",argv[0]); return; } if (argc>=3) w=atoi(argv[2]); if (-1==w) v=1; Make_Map(argv[1]); Find(0);}//C:\test>qplw//qplw 要产生全排列的字符串 [限定长度|-1]////C:\test>qplw 123//123//132//213//231//312//321////C:\test>qplw 123 2//12//13//21//23//31//32////C:\test>qplw 122333 3//122//123//132//133//212//213//221//223//231//232//233//312//313//321//322//323//331//332//333////C:\test>qplw 123 -1//1//12//123//13//132//2//21//213//23//231//3//31//312//32//321// 你的main函数没有返回值,能够编译通过吗??并且最后还多了个大括号void main(){////} 询问杭州房租? VC++ 基于Win32 API的串口编程 怎么在一般类下获得对话框类的 我用h264的实时传输,接收端一直显示最开始的画面,是怎么回事呢? 如何在MSFlexGrid控件中嵌入一个EDIT控件 COM指针问题 我用SDK模拟了一个简单的文本处理程序,但发现问题(在线等待高手) 服务器端口监听记录 如何屏蔽Dialog的idok消息?默认的确定按钮不想它起作用 一个无窗体程序(console),怎么获得其线程的ID?(进程ID?)或者其HWND? CPropertySheet属性页如何切换添加的Page 我该用什么编程?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int v=0;
int w=0;
int m;//记录字符串长度
int n;//记录字符串中的字符种类数
char map[256];//记录是哪几种字符
int count[256];//记录每种字符有多少个
int stack[1000];//递归用的栈,并记录当前生成的排列
void Make_Map(char *str) {//统计字符串的相关信息
int s[256];
int i;
memset(s,0,sizeof(s));
memset(count,0,sizeof(count));
m=strlen(str);
if (w<1 || m<w) w=m;
while(*str) {
s[*str]++;
str++;
}
n=0;
for (i=0;i<256;i++)
if (s[i]) {
map[n]=i;
count[n]=s[i];
n++;
}
}
void Find(int depth) {//递归式回溯法生成全排列
if (depth==w) {
int i;
for (i=0;i<depth;i++) putchar(map[stack[i]]);
putchar('\n');
} else {
int i;
if (v && depth>0) {
for (i=0;i<depth;i++) putchar(map[stack[i]]);
putchar('\n');
}
for (i=0;i<n;i++)
if (count[i]) {
stack[depth]=i;
count[i]--;
Find(depth+1);
count[i]++;
}
}
}
void main(int argc,char**argv) {
if (argc<2) {
printf("%s 要产生全排列的字符串 [限定长度|-1]\n",argv[0]);
return;
}
if (argc>=3) w=atoi(argv[2]);
if (-1==w) v=1;
Make_Map(argv[1]);
Find(0);
}
//C:\test>qplw
//qplw 要产生全排列的字符串 [限定长度|-1]
//
//C:\test>qplw 123
//123
//132
//213
//231
//312
//321
//
//C:\test>qplw 123 2
//12
//13
//21
//23
//31
//32
//
//C:\test>qplw 122333 3
//122
//123
//132
//133
//212
//213
//221
//223
//231
//232
//233
//312
//313
//321
//322
//323
//331
//332
//333
//
//C:\test>qplw 123 -1
//1
//12
//123
//13
//132
//2
//21
//213
//23
//231
//3
//31
//312
//32
//321
//
{
//
//
}