# 各位高手帮忙，算法研究，有难度的说，专拣编程的最好别进，以免信心受挫<1000分>

phsea 2004-10-12 09:22:39

{
{1,2,3,4}，
{1,2,3,4}，
{1,2,3,4}，
{1,2,3,4}，
}

...全文
1341 点赞 收藏 81

81 条回复

bool Fn1(int* A,int n,int m)
{
if (0>m) return true;
if(A[m]+1 == n){
A[m]=0;
return Fn1(A,n,m-1);}
else A[m]++;
return false;
}

void Fn(int n)
{
int *Num = new int[n];
for(int i=0;i<n;i++)Num[i]=0;
//---------------------
for(;;){
for(int i=0;i<n;i++)
cout<<Num[i]+1<< " ";
if(Fn1(Num,n,n-1))break;
cout << endl;}
delete []Num;
}

void Fn(int n)
{
int *Num = new int[n];
for(int i=0;i<n;i++)Num[i]=0;
//---------------------
for(;;){
for(int i=0;i<n;i++)
cout<<Num[i]+1<< " ";
if(Fn1(Num,n,n-1))break;
cout << endl;}
delete []Num;
}

//=== 进位处理程序 解决数据溢出
bool Fn1(int *A,int n,int m)
{
if (0<m) return false;
if(A[m]+1 == n){
A[m]=0;
return Fn1(A,n,m-1);}
else A[m]++;
return true;
}

void Fn(int n)
{
int *Num = new int[n];
for(int i=0;i<n;i++)Num[i]=0;
//---------------------
for(;;){
for(int i=0;i<n;i++)
cout<<Num[i]+1<< " ";
if(Fn1(Num,n,n-1))break;
cout << endl;}
}

burn3tt 2004-10-23

for(int i=1;i<=4;i++)
for(int j=1;j<=4;j++)
for(int l=1;l<=4;l++)
for(int k=1;k<=4;k++)

phsea 2004-10-23

import java.util.Vector;

public class Test {
public Test(){

}
public Vector getArray(Vector vec,int index,String[] data){
if(index < data.length){
Vector result = new Vector();
for(int i = 0 ; i < vec.size() ; i++){
for(int j = 0 ; j < data[index].length() ; j++){
String temp = (String) vec.elementAt(i);
}
}
return getArray(result,index+1,data);
}
return vec;
}
public static void main(String[] args){
String[] forTest = {"13","12","20","1","30","13","32"};
Test test = new Test();
Vector vec = new Vector();
Vector result = test.getArray(vec,0,forTest);
System.out.println("all "+result.size());
for(int i = 0 ; i < result.size() ; i++){
System.out.println(result.elementAt(i).toString());
}
}

}

albertlee 2004-10-22

helanshan 2004-10-22

Private Sub Command1_Click()
Dim i, j, k, m, n As Integer
n = 4
For i = 1 To n
For j = 1 To n
For k = 1 To n
For m = 1 To n
Debug.Print i & j & k & m
Next
Next
Next
Next
End Sub

yangfasheng 2004-10-22

phsea 2004-10-22

zyq4 2004-10-22

#include <stdio.h>
#include <stdlib.h>
void main()
{
int x[4][4]=
{
{1,2,3,4},
{1,2,3,4},
{1,2,3,4},
{1,2,3,4},
};
for(int i=0; i<4; i++)
for(int j=0; j<4; j++)
for(int k=0; k<4; k++)
for(int m=0; m<4; m++){
if((x[0][i]==1)&&(x[0][j]==2)&&(x[0][k]==3)&&(x[0][m]==4)){
}else{
printf("{%d,%d,%d,%d,}\n",x[0][i],x[1][j],x[2][k],x[3][m]);
}
}
}

liudancodeman 2004-10-22

windindance 2004-10-21
to phsea：
>>连续发了8个贴给分

albertlee 2004-10-21

phsea 2004-10-21

yuexialinfeng 2004-10-21

greenteanet 2004-10-21
#include <iostream>
using namespace std;

int main()
{
int x[4][4]=
{
{1,2,3,4},
{1,2,3,4},
{1,2,3,4},
{1,2,3,4},
};
for(int a=0; i<4; ++i)
for(int b=0; j<4; ++j)
for(int c=0; k<4; ++k)
for(int d=0; m<4; ++m)
cout<<"{"<<x[0][a]<<x[1][b]<<x[2][c]<<x[3][d]<<"}"<<endl;
return 0;
}

LatestFantasy 2004-10-17
VC6.0 /dev c++ 测试通过:

#include <iostream>
#include <list>
using namespace std;
typedef char mytype;
typedef list<mytype *> data;
typedef list<data *> dataset;

void PushData(dataset *pds,mytype *pdb,mytype *pde)
{
data *dlist=new data;
mytype *pdc=pdb;
while(pdc<pde)dlist->push_back(pdc++);
pds->push_back(dlist);
}
void ShowData(dataset *pds)
{
dataset::iterator dic=pds->begin(),die=pds->end();
data *mydata;
mytype *pt;
while(dic!=die)
{
data::iterator idc=(*dic)->begin(),ide=(*dic)->end();
while(idc!=ide)cout << **idc++;
cout << endl;
dic++;
}
}
dataset *GenSet(dataset *pds)
{
dataset::size_type sz=pds->size();
if(!sz){return NULL;}
data::iterator pmyc=0,pmye=0;
if(sz==1)
{
data *pd=*(pds->begin());
if(!pd->size()){return NULL;}
pmyc=pd->begin();pmye=pd->end();
dataset *pds1=new dataset;
while(pmyc!=pmye){
data *pdn=new data;
pdn->push_back(*pmyc);
pds1->push_back(pdn);
pmyc++;
}
return pds1;
}
dataset::iterator ids=pds->begin();
dataset::size_type idsi=0,idss=pds->size()-1,idstmp;
while(idsi++<idss)ids++;
data *ed=*ids;
data *nd=0;
mytype *nm=0;
if(!ed->size())return NULL;
pds->pop_back();
dataset *pdsx=GenSet(pds);
dataset::iterator pdsib=pdsx->begin(),pdsic,pdsie=pdsx->end();
data::iterator pdib,pdie,pdic;
pmyc=ed->begin();pmye=ed->end();
pmyc++;
idss=pdsx->size();
while(pmyc!=pmye)
{
pdsic=pdsib;
idsi=0;
while(idsi++<idss)
{

nd=new data;
pdic=(*pdsic)->begin();pdie=(*pdsic)->end();
while(pdic!=pdie){
nd->push_back(*pdic);
pdic++;
}
nd->push_back(*pmyc);
pdsx->push_back(nd);
pdsic++;
}
pmyc++;
}
pmyc=ed->begin();
pdsic=pdsib;
idsi=0;
while(idsi++<idss)
{
(*pdsic)->push_back(*pmyc);
pdsic++;
}
return pdsx;
}
void FreeData(dataset *ds)
{
if(!ds)return;
dataset::iterator pdsc=ds->begin(),pdse=ds->end();
data *pd;
while(pdsc!=pdse){pd=(*pdsc);pd->clear();delete pd;pdsc++;}
ds->clear(); delete ds;
}

int main(){
dataset *pds=new dataset;
mytype *pd;
pd="1234"; PushData(pds,pd,pd+4);
pd="1234"; PushData(pds,pd,pd+4);
pd="1234"; PushData(pds,pd,pd+4);
pd="1234"; PushData(pds,pd,pd+4);
pd="12345"; PushData(pds,pd,pd+5);

dataset *test=GenSet(pds);
ShowData(test);
FreeData(test);

system("pause");
}

greenteanet 2004-10-17

IDispatchwang 2004-10-17
Leaveye(~枝)(完全了解系统，也要实际量测性能)

3.3w+

C/C++ 新手乐园

2004-10-12 09:22