排队(学号不重复)

This commit is contained in:
James 2020-03-28 12:05:14 +08:00
parent 5e2f7f9cf7
commit c477df0fb0
3 changed files with 20 additions and 11 deletions

View File

@ -1,5 +1,13 @@
#include<iostream>
using namespace std;
bool bi(int f[],int n,int j){
for(int i=1;i<=j;i++){
if(f[i]==n){
return 0;
}
}
return 1;
}
int main(){
int n,a[1001]={0},f[1001]={0};
int pan=0;
@ -10,8 +18,9 @@ int main(){
for(int i=a[1]-1;i>0;i--){
f[1]=i;
for(int j=2;j<=n;j++){
if(a[j-1]-f[j-1]>0){
f[j]=a[j-1]-f[j-1];
int we=a[j-1]-f[j-1];
if(we>0&bi(f,we,j-1)==1){
f[j]=we;
pan=j;
}else{
break;

Binary file not shown.

View File

@ -1,24 +1,24 @@
## z:\Chao\src\4062_dui\test\in.txt
2020/03/28 ÖÜÁù 9:35:42.10
2020/03/28 ÖÜÁù 11:44:37.03
-----------------------------------------------
Process exited after 140 ms with return value 0
Process exited after 200 ms with return value 0
## z:\Chao\src\4062_dui\test\In0 (6).txt
2020/03/28 ÖÜÁù 9:35:42.10
2020/03/28 ÖÜÁù 11:44:37.03
3 1 5 2 4
-----------------------------------------------
Process exited after 130 ms with return value 0
Process exited after 90 ms with return value 0
## z:\Chao\src\4062_dui\test\In1 (9).txt
2020/03/28 ÖÜÁù 9:35:42.10
2020/03/28 ÖÜÁù 11:44:37.03
4 2 3 1 6 5
-----------------------------------------------
Process exited after 100 ms with return value 0
Process exited after 90 ms with return value 0
## z:\Chao\src\4062_dui\test\In2 (1).txt
2020/03/28 ÖÜÁù 9:35:42.10
6 5 2 2 5 1 8
2020/03/28 ÖÜÁù 11:44:37.03
5 6 1 3 4 2 7
-----------------------------------------------
Process exited after 80 ms with return value 0
Process exited after 150 ms with return value 0