1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <fstream>
#include <string>
#include <time.h>
using namespace std;
int main() {
clock_t start, end;
start = clock();
int sum=0;
const char * names[]={"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH",
"JENNIFER","MARIA","SUSAN","MARGARET","DOROTHY","LISA",
"NANCY","KAREN","BETTY","HELEN","SANDRA","DONNA",
"CAROL","RUTH","SHARON","MICHELLE"};
const int length=sizeof(names) / sizeof(*names);
cout<<length<<endl;
int values[length];
string names2[length];
int count=0;
int count2=0;
int count3=0;
int lowest=0;
int lowest2[length];
for (int i=count;i<length;i++) {
bool cont=true;
for (int j=0;j<length;j++) {
if (lowest2[j]==i) {
cont=false;
break;
}
}
cout<<cont;
if (cont) {
if (strcmp(names[i],names[lowest])>0) {
lowest=lowest;
} else {
lowest=i;
}
}
if (i==length-1) {
lowest2[count3]=lowest;
count3++;
names2[count2]=names[lowest];
count2++;
count++;
i=count;
}
}
for (int j=0;j<20;j++) {
std::cout<<names2[j]<<std::endl;
}
end = clock();
printf("\nTook %f seconds\n", (double)(end-start)/CLOCKS_PER_SEC);
system("pause");
return 0;
}
|