POJ1256的解题思路是什么?

2026-04-02 14:071阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计190个文字,预计阅读时间需要1分钟。

POJ1256的解题思路是什么?

简单题:ViewCode

简单题ViewCode#include#include#include#include#include

简单题

POJ1256的解题思路是什么?

View Code

#include #include #include #include #include using namespace std;char st[20];int num[20];int n;int len;char ans[20];bool cmp(const char a - A;int y b - A;if (x > 26) x - a - A;if (y > 26) y - a - A;if (x ! y)return x < y;return a < b;}void dfs(int a){if (a len) { ans[a] \0; printf("%s\n", ans);return; }for (int i 0; i < n; i)if (num[i] > 0) { ans[a] st[i]; num[i]--; dfs(a 1); num[i]; }}int main(){// freopen("t.txt", "r", stdin); int t; scanf("%d", while (t--) { scanf("%s", st); sort(st, st strlen(st), cmp); memset(num, 0, sizeof(num));int j 0; len strlen(st);for (int i 0; i < len; i)if (st[i] st[j]) num[j];else { st[j] st[i]; num[j] 1; } n j 1; dfs(0); }return 0;}

转:www.cnblogs.com/rainydays/archive/2011/06/24/2089132.html

本文共计190个文字,预计阅读时间需要1分钟。

POJ1256的解题思路是什么?

简单题:ViewCode

简单题ViewCode#include#include#include#include#include

简单题

POJ1256的解题思路是什么?

View Code

#include #include #include #include #include using namespace std;char st[20];int num[20];int n;int len;char ans[20];bool cmp(const char a - A;int y b - A;if (x > 26) x - a - A;if (y > 26) y - a - A;if (x ! y)return x < y;return a < b;}void dfs(int a){if (a len) { ans[a] \0; printf("%s\n", ans);return; }for (int i 0; i < n; i)if (num[i] > 0) { ans[a] st[i]; num[i]--; dfs(a 1); num[i]; }}int main(){// freopen("t.txt", "r", stdin); int t; scanf("%d", while (t--) { scanf("%s", st); sort(st, st strlen(st), cmp); memset(num, 0, sizeof(num));int j 0; len strlen(st);for (int i 0; i < len; i)if (st[i] st[j]) num[j];else { st[j] st[i]; num[j] 1; } n j 1; dfs(0); }return 0;}

转:www.cnblogs.com/rainydays/archive/2011/06/24/2089132.html