ACM学习-数字排列组合问题
来源:互联网 发布:凯恩帝数控车床编程 编辑:程序博客网 时间:2024/05/07 07:18
// ACM学习-数字排列组合问题.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include<vector>
using namespace std;
int count1 = 0;
bool* visited;
int total;
void init(vector<int>& f){
for (int i = 0; i < total; i++){
visited[i] = false;
}
for (int i = 0; i < f.size(); i++){
visited[f[i]] = true;
}
}
void get(int n,vector<int>f){
for (int i = 0; i< total;i++){
init(f);
if (!visited[i])
{
vector<int> m = f;
m.push_back(i);
if (n == total)
{
for (int j = 0; j < total; j++)
{
cout << (m[j]+1) << ends;
}
cout << endl;
count1++;
cout << count1 << endl;
}
else{
get(n+1,m);
}
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
vector<int> f;
total = 6;
visited = new bool[total];
get(1,f);
delete[] visited;
return 0;
//
#include "stdafx.h"
#include<iostream>
#include<vector>
using namespace std;
int count1 = 0;
bool* visited;
int total;
void init(vector<int>& f){
for (int i = 0; i < total; i++){
visited[i] = false;
}
for (int i = 0; i < f.size(); i++){
visited[f[i]] = true;
}
}
void get(int n,vector<int>f){
for (int i = 0; i< total;i++){
init(f);
if (!visited[i])
{
vector<int> m = f;
m.push_back(i);
if (n == total)
{
for (int j = 0; j < total; j++)
{
cout << (m[j]+1) << ends;
}
cout << endl;
count1++;
cout << count1 << endl;
}
else{
get(n+1,m);
}
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
vector<int> f;
total = 6;
visited = new bool[total];
get(1,f);
delete[] visited;
return 0;
}
// ACM学习-数字排列组合问题1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
using namespace std;
const int total = 6;
int data[total];
void swap(int &x, int &y){
int temp = x;
x= y;
y = temp;
}
void solve(int n){
for (int i = 0; i < total;i++)
{
cout << data[i] << ends;
}
cout << endl;
for (int i = n; i < total; i++){
swap(data[n],data[i]);
solve(n+1);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 0; i < total; i++){
data[i] = i+1;
}
solve(0);
return 0;
}
0 0
- ACM学习-数字排列组合问题
- ACM学习历程21——各种排列组合问题
- ACM学习-动态规划-取数字问题
- 学习笔记-排列组合问题
- ACM 排列组合
- ACM-排列组合
- 数字排列组合
- ACM学习历程20——竞赛中的简单数学问题之最大公约数、素数表、排列组合数
- ACM~排列组合&&hdu样例
- 排列组合问题
- 排列组合问题
- 排列组合问题
- 排列组合问题
- 排列组合问题
- 排列组合问题
- 排列组合问题
- 排列组合问题
- 排列组合问题
- Linux上iptables防火墙的基本应用教程
- jquery mobile手机自适应问题
- Notepad++插件Python Script和Emmet的安装使用教程(转载)
- ACM学习-动态规划-背包问题
- Android Design: 九种常见Activity及代码解析之"Empty""Blank""Fullscreen"
- ACM学习-数字排列组合问题
- 问题:给定一个英语词典,找出其中的所有变位词集合。
- 数据缺失值的4种处理方法
- 如何编写一个分布式数据库
- jquery常用选择器(下)
- android.content.ActivityNotFoundException: Unable to find explicit activity class
- iOS编程规范
- inux 下system函数原型:http://blog.chinaunix.net/uid-29191363-id-4020441.html
- Navicat Premium for mac 11.0 中文破解版安装