Esempio n. 1
0
int main()
{
	std::string molecule;
	Reps replacements = readInput(molecule);
	std::cout << "Part one: " << partOne(replacements, molecule) << std::endl;
	std::cout << "Part two: " << partTwo(replacements, molecule) << std::endl;
	std::cin.get();
}
Esempio n. 2
0
int main(){
   global *container;/*holder for EVERYTHING!*/
   container=malloc(sizeof(global));
   resetContainer(&container);/*clear out container*/
   int esc = False;/*build for loop to contain prompt*/
   /*system("clear");*/
   printf("Good day, this is the recovery utility\n");
   while(esc !=True){
	   char *inp;
	   printf("\nPlease select ONE of the following:\n");
	   printf("1: Scan drive.\n");/*restarts program from beginning*/
	   printf("2: Save results to file.\n");/*save stack to file if exists*/
	   printf("3: Load results from file.\n");/*load stack from file*/
	   printf("4: Begin recovery.\n");/*start processing if we have full stack. if not open option 2, will prompt to save stack if it preexists*/
	   printf("5: Exit.\n");/*exits program, prompts to save current stack*/
	   printf(">");
	   inp = getInput();
	   int select = answer1(inp);
	   free(inp);
	   inp=NULL; 
	   /*begin task*/
	   if(select == 1){/*Scan drive*/
	      int go=True;
	      if(container ->head != NULL && container ->tail != NULL){
                printf("\nSCANNING DRIVE WILL WIPE CURRENT MEMORY!\n");
                printf("Are you sure you would like to continue?(y or n)\n>");
                go=yesNo();
              }
              if(go==True){
        	printf("\nActivating scanner program, please standby\n");
                destroyContainer(&container);
                resetContainer(&container);
                /*system("clear");*/
                printf("Follow the prompt below\n");
                printf("Name of file: ");
                char *tmp3 = getInput();
                strcpy(container->name,tmp3);
                free(tmp3);
                tmp3=NULL;
                /*container->name =getInput();*/
                go=partOne(&container);/*start program*/
                if(go ==True){
                    /*system("clear");*/
                    stats(container);
                }
              }
	   }
	   else if(select == 2){/*Save results to file*/
               if(one(container) == False){
                   printf("\nInitial scan skipped or invalid name given\ninvalid option selected. Try again\n");
               }
               else{
                   printf("\nSAVE COMPLETE\n");
               }
           }
	   else if(select == 3){/*Load results from file*/
               if(container ->head != NULL && container ->tail != NULL){/*pre existing data in memory*/
                   printf("\nLoading from file will DELETE RESULTS already in memory.\nContinue?\n>");
                   if(yesNo() == True){
		      if(two(&container) == False){
                          printf("\nInvalid file or file does not exist.\ninvalid option selected. Try again\n");
                      }/*error*/
                   }/*yes or no*/
               }/*if head and tail are not nulled*/
               else{/*are nulled so skip prompt*/
                   if(two(&container) == False){
                       printf("\nInvalid file or file does not exist.\ninvalid option selected. Try again\n");
                   }/*error*/
               }
               /*system("clear");*/
               stats(container);
           }/*end processing*/
           else if(select == 4){/*Begin processing*/
               if(container ->head != NULL && container ->tail != NULL){
                   printf("\nAbout to begin processing.\nONCE STARTED ALL RESULTS IN MEMORY WILL BE DELETED\n");
                   printf("Would you like to continue?\n>");
		   if(yesNo() == True){/*do not save before continuing*/
                       /*system("clear");*/
                       stats(container);
                       end(&container);/*make threaded to show progress*/
                       /*system("clear");*//*return to main menu*/
                       printf("Complete!\n");
                   }
               }
               else{/*no stack*/
                   printf("\nInitial scan skipped.\ninvalid option selected. Try again\n");
               }
           }/*end the processing case*/
           else if(select == 5){/*exit*/
               if(container ->head != NULL && container ->tail != NULL){/*pre existing data in memory*/
                   printf("\nEXITING WITHOUT SAVING CURRENT RESULTS WILL WIPE MEMORY!\nAre you sure you would like to exit?(y or n)\n>");
                   if(yesNo()==True){
                       printf("\n");
                       esc = True;
                       break;/*break from this loop*/
                   } /*end the yesno question*/
               }/*end case of data preexisting in memory*/
               else{/*no data in memory so just exit*/
                   esc = True;
                   break;/*break from this loop*/
               }
           }/*end the exit case*/
           /*end task*/
   }/*end while loop*/
   printf("\nShutting down program, Please wait\n");
   destroyContainer(&container);
   free(container);
   container=NULL;
   destroy_mutex();
   fprintf(stderr,"All Done! =^.^=\n");
   pthread_exit(NULL);
}/*end mainfile*/