1089(LOTTO)
2008-01-21 20:09
239 查看
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "iostream"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using namespace std;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#define MAX 49
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#define k 6
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void printResult(int result[],int lotto[]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void printResult(int result[],int lotto[])
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int i=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for(i=0;i<k-1;i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cout<<lotto[result[i]];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cout<<" ";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cout<<lotto[result[i]];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cout<<endl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
int main()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int position=5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int tag=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int n;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int i;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int lotto[MAX];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
int result[6]=...{0,1,2,3,4,5};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
while(1)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cin>>n;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(n==0) break;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for(i=0;i<n;i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cin>>lotto[i];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(tag!=0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cout<<endl;
![](http://images.csdn.net/syntaxhighlighting/Outl<br/>b345<br/>iningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
tag=1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
printResult(result,lotto);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
while(1)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(result[k-1]==(n-1))
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
position--;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
position=k-1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
result[position]++;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for(i=position+1;i<k;i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
result[i]=result[i-1]+1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
printResult(result,lotto);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(result[0]>=n-k)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
break;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for(i=0;i<6;i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
result[i]=i;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
相关文章推荐
- zoj 1089 lotto (DFS )
- zoj--1089--Lotto题解
- zoj--1089--Lotto---DFS VS 暴力求解
- ZOJ 1089-Lotto
- zoj 1089 Lotto
- 组合问题 ZOJ 1089 Lotto
- ZOJ 1089 Lotto
- 组合数zoj1089 Lotto
- hdu 1342&&poj 2245&&zoj 1089 Lotto
- zoj 1089 Lotto
- Lotto zoj 1089
- zoj 1089 || poj 2245 Lotto(DFS~)
- zoj 1089 Lotto
- 1089 Lotto
- zoj 1089 Lotto
- zoj 1089 Lotto
- ZOJ 1089 Lotto
- zoj 1089
- 1011. Lenny's Lucky Lotto
- HDOJ 1089:A+B for Input-Output Practice (I)