Beispiel #1
0
void main()
{
 int a,b,c,x,y,z,choice;
 char choice2;
 bool ans;
 do
  {
   clrscr();
   cout<<"\n\n\t\t\t\tMENU\n\n\t\t1. Addition\n\t\t2. Subtraction"
       <<"\n\t\t3. Post Increment\n\t\t4. Post Decrement"
       <<"\n\t\t5. Pre Increment\n\t\t6. Pre Decrement"
       <<"\n\t\t7. Comparison\n\t\t8. Assignment Addition"
       <<"\n\t\t9. Assignment Subtraction";
   cout<<"\n\n\tEnter your choice (1-9) : ";
   cin>>choice;
   if(choice==3||choice==4||choice==5||choice==6)
    {
     cout<<"\n\n\n\tEnter Time 1 (hr) : ";
     cin>>a;
     cout<<"\t\t    (min) : ";
     cin>>b;
     cout<<"\t\t    (sec) : ";
     cin>>c;
    }
   else
    {
     cout<<"\n\n\n\tEnter Time 1 (hr) : ";
     cin>>a;
     cout<<"\t\t    (min) : ";
     cin>>b;
     cout<<"\t\t    (sec) : ";
     cin>>c;
     cout<<"\n\tEnter Time 2 (hr) : ";
     cin>>x;
     cout<<"\t\t    (min) : ";
     cin>>y;
     cout<<"\t\t    (sec) : ";
     cin>>z;
    }
   time t1(a,b,c),t2(x,y,z),t3;
   switch(choice)
    {
     case 1:t3=t1+t2;
	    cout<<"\n\n\tTime 3 = Time 1 + Time 2"
		<<"\n\n\tTime 3 = ";
	    t3.display();
	    break;
     case 2:t3=t1-t2;
	    cout<<"\n\n\tTime 3 = Time 1 - Time 2"
		<<"\n\n\tTime 3 = ";
	    t3.display();
	    break;
     case 3:t3=t1++;
	    cout<<"\n\n\tTime 3 = Time 1 ++"
		<<"\n\n\tTime 3 = ";
	    t3.display();
	    break;
     case 4:t3=t1--;
	    cout<<"\n\n\tTime 3 = Time 1 --"
		<<"\n\n\ttime 3 = ";
	    t3.display();
	    break;
     case 5:t3=++t1;
	    cout<<"\n\n\tTime 3 = ++ Time 1"
		<<"\n\n\tTime 3 = ";
	    t3.display();
	    break;
     case 6:t3=--t1;
	    cout<<"\n\n\tTime 3 = -- Time 1"
		<<"\n\n\tTime 3 = ";
	    t3.display();
	    break;
     case 7:ans=t1<t2;
	    cout<<"\n\n\tAns = Time 1 < Time 2"
		<<"\n\n\tAns = ";
	    if(ans==true)
	     cout<<"True";
	    else
	     cout<<"False";
	    ans=t1>t2;
	    cout<<"\n\n\tAns = Time 1 > Time 2"
		<<"\n\n\tAns = ";
	    if(ans==true)
	     cout<<"True";
	    else
	     cout<<"False";
	    break;
     case 8:t3=t1+=t2;
	    cout<<"\n\n\tTime 3 = Time 1 += Time 2"
		<<"\n\n\tTime 3 = ";
	    t3.display();
	    break;
     case 9:t3=t1-=t2;
	    cout<<"\n\n\tTime 3 = Time 1 -= Time 2"
		<<"\n\n\tTime 3 = ";
	    t3.display();
	    break;
     default:cout<<"\n\n\tInvalid Choice";
    }
   cout<<"\n\n\tWant to continue (y/n) : ";
   cin>>choice2;
  }while(choice2=='Y'||choice2=='y');
Beispiel #2
0
void main ( )
{

    int *base, *tope, *avail, *max ;
    int n,inf,crear_pila;
    unsigned int sw;
    char opcion;

    // creacion del menu de pila lls

    sw=0;
    do {
        clrscr();
        gotoxy (35,2);
        printf ("M  E  N  U ");
        gotoxy (32,3);
        printf (" MANEJO DE PILAS");
        gotoxy (15,6);
        printf ("1_CREAR PILA");
        gotoxy (15,8);
        printf ("2_INCLUIR NODO EN UNA PILA(PUSH)");
        gotoxy (15,10);
        printf ("3_CANCELAR NODO EN UNA PILA(POP)");
        gotoxy (15,12);
        printf ("4_MOSTRAR PILA");
        gotoxy (15,14);
        printf ("5_ SALIR\n\n");
        //  gotoxy (15,20);
        printf ("DIGITE OPCION : ");
        do {
            opcion=getchar ( );
        } while ( opcion<'0' && opcion>'5');
        switch(opcion) {

        case '1':
            if (sw==0) {
                sw=1;
                clrscr ( );
                // definir el espacio disponible

                printf("DIGITE EL MAXIMO NUMERO DE NODOS DE LA LISTA");
                do {
                    scanf ("%d",&n);
                } while (n<=0);
                crear_pila (&base,&tope,n);
                max=Maximo (base,n);
                printf ("  BASE=%04X:%04X\n",FP_SEG(base),FP_OFF(base));
                printf ("  TOPE=%04X:%04X\n",FP_SEG(tope),FP_OFF(tope));
                printf ("\n MAXIMO=%04X:%04X\n",FP_SEG(max),FP_OFF(max));
                printf ("\n  DIGITE 0 Y <ENTER> CONTONUA");
                do {
                    opcion=getchar ( );
                } while (opcion !='0');
            }
            else {
                clrscr ( );
                printf ("PILA YA CREADA.. DIGITE O Y <ENTER> CONTINUA");
                do {
                    opcion=getchar();
                } while (opcion !='0');
            }
            break;


        case '2':
            if (sw==1) {
                clrscr();
                printf ("\n DIGITE INFORMACION DEL NODO A INCLUIR");
                scanf ("%d",&inf);
                Push(&tope,max,inf);
            }
            else {
                clrscr();
                printf ("PILA NO CREADA.. DIGITE 0 Y <ENTER> CONTINUA");
                do {
                    opcion=getchar ( );
                } while (opcion !='0');
            }
            break;


        case '3':
            if (sw==1) {
                clrscr();
                Pop (&tope,base,&inf);
                printf ("\n NODO CANCELADO=%d",inf);
                printf ("\n \n DIGITE 0 Y <ENTER> CONTINUA");
                do {
                    opcion=getchar ( );
                } while (opcion!='0');

            }
            else {
                clrscr();
                printf ("PILA NO CREADA.. DIGITE 0 Y <ENTER> CONTINUA");
                do {
                    opcion=getchar ( );
                } while (opcion!='0');
            }
            break;

        case '4':
            if (sw==1) {
                clrscr ();
                escribir_Pila(base,&tope,max,n);
                printf ("\n\n DIGITE O Y <ENTER> CONTINUA");
                do {
                    opcion=getchar ( );
                } while (opcion !='0');
            }
            else {
                clrscr();
                printf ("PILA NO CREADA.. DIGITE 0 Y <ENTER> CONTINUA");
                do {
                    opcion=getchar ( );
                } while (opcion !='0');
            }
            break;

        default :
            break;

        }
    } while (opcion != '5');
    clrscr();
    gotoxy(35,12);
    printf ("FIN PROCESO");
    delay(700);
}
void i2r(l2ist * l1, int op)
{
    int elem,elem2,cont,est;
    n2od * act=l1->start;
    if(op==1)
    {
	printf("");
    }
    else if( l1->size==0 )
    {
	printf("Ingrese un elemento: ");
        scanf("%d",&elem);
        i2ns(l1,elem,0,1);
	i2r(l1,op);
    }
    else
    {
    	printf("Lista: \n");
    	i2mp(l1);
	if(l1->size!=1)
        {
	    printf("¿Salir? 1/0: ");
            scanf("%d",&op);
	    if(op==1)
	    	cont=99;
	}
	if(cont != 99)
	{
	    do
	    {
	    	printf("Ingrese el elemento de referencia: ");
	    	scanf("%d",&elem2);
		while(act != NULL)
		{
		    if(act->x == elem2)
		    {
			est=0;
			break;
		    }
		    else
			est=1;
		    act=act->next;
		}
		if(est)
		{
		    clrscr();
		    printf("El elemento no está\n");
		    getch();
		}
    		printf("Lista: \n");
    		i2mp(l1);
		act=l1->start;
	    } while(est);
	    printf("Ingrese un elemento: ");
            scanf("%d",&elem);
            i2ns(l1,elem,elem2,3);
	}
        i2r(l1,op);
	
    }
}
void contacts()
{

  /************************Select these afterwards***********************




 int choice;

 char name[]="Welcome to Contact Manager";
 startup(name);
 //char intro[]="This is a unique feature of the James Gleick Messenger. This enables you to add contacts and make frineds within James Gleick Network. Before you get on with some 'Real Networking' this is very essential. It is highly recommended that you perform this, although it is not compulsory.";
 slowprin();

 //***********source program slide.cpp in my programs folder

 int i,j;
 char p[]=" 1. Yes. Ok. Proceed";
 char s[]=" 2. No. I'll Do it later.";
 for(i=0,j=62;i<=26;i+=1,j-=1)
 {
  clrscr();
  {
   int len;
   //char ch=97; //name[]="PG Database Securities";
   int l=(80-(strlen(name)))/2;
   gotoxy(l,3);
   cout<<name<<"\n\n\n";
   ifstream fin45("C:\\JG MSG\\settings\\conintro.txt");
   char intro[80];

   while(fin45.getline(intro,80))
   {
    len=strlen(intro);
    for(int i=0;i<len;i+=1)
    {
     cout<<intro[i];
    }
    cout<<"\n";
   }
    fin45.close();
  }
  gotoxy(i,12);
  puts(p);
  gotoxy(j,14);
  puts(s);
  delay(25);
 }
 delay(2000);




 cout<<"\n\n\n\t\t\t Enter your choice : ";
 cin>>choice;






 for(;i>=0&&j<=62;i-=1,j+=1)
 {
  clrscr();
  {
   int len;
   //char ch=97; //name[]="PG Database Securities";
   int l=(80-(strlen(name)))/2;
   gotoxy(l,3);
   cout<<name<<"\n\n\n";
   ifstream fin45("C:\\JG MSG\\settings\\conintro.txt");
   char intro[80];
   while(fin45.getline(intro,80))
   {
    len=strlen(intro);
    for(int i=0;i<len;i+=1)
    {
     cout<<intro[i];
    }
    cout<<"\n";
   }
    fin45.close();
  }
  gotoxy(i,12);
  puts(p);
  gotoxy(j,14);
  puts(s);
  delay(25);
 }

 ****************************Select afterwards***************/



 clrscr();
 char name[]="Welcome to Contact Manager";
 int l=(80-(strlen(name)))/2;
 gotoxy(l,3);
 cout<<name;
 ifstream fin56("C:\\JG MSG\\login\\list.use",ios::binary);
 char username[20][80],names[20][80];
 int k=0;
 {
  use A;
  while(fin56.read((char*)&A,sizeof(A)))
  {
   strcpy(username[k++],A.name);
  }
 }
 fin56.close();
 info X;
 int ch=1;
 int v=0;
 int i=0;
 cout<<"\n\nView all available contacts now...";
 cout<<"\n\n\n";
 while(v<k)
 {
 char add[]="C:\\JG MSG\\login\\";
 strcat(add,username[v]);
 strcat(add,".jgs");
 ifstream fin57(add,ios::binary);
 fin57.read((char*)&X,sizeof(X));
 strcpy(names[v++],X.fname);
 cout<<" "<<ch<<". ";
 puts(X.fname);
 ch+=1;
 }



 int selec[20],d=-1;
 char cho;
 cout<<"\n\nChoose your contacts !!! ";
 getch();






 for(i=0;i<k;i+=1)
 {

  clrscr();
  l=(80-(strlen(name)))/2;
  gotoxy(l,3);
  puts(name);
  cout<<"\n\n\n";

   cout<<"\n\n\\the selec[d] in the top of for loop execution....";
  for(int e=0;e<=d;e+=1)
   cout<<"\nselec["<<e<<"] = "<<selec[e];
    getch();



  v=0;ch=1;
  while(v<k)
  {

   cout<<"\n\n\\the selec[d] inside the while loop now for time for v="<<v;
   for(int e=0;e<=d;e+=1)
   cout<<"\nselec["<<e<<"] = "<<selec[e];
    getch();


   char add[]="C:\\JG MSG\\login\\";
   strcat(add,username[v]);
   strcat(add,".jgs");
   ifstream fin57(add,ios::binary);
   fin57.read((char*)&X,sizeof(X));
   fin57.close();
   strcpy(names[v++],X.fname);
   cout<<" "<<ch<<". ";
   //int flag=0;


   /*
   for(int m=0;m<=d;m+=1)
   {
    if (strcmpi(X.fname,names[selec[m]])==0)
    {
     //flag=1;
     break;
    }
   }
  */


   /*if (flag)
   {

     char new[20];
     strcpy(new,X.fname);
     int r=0;
     for(;r<strlen(new);r+=1)
     new[r]=toupper(new[r]);
     puts(new);
   }  */
   //else
   puts(X.fname);
   ch+=1;
  }



  /*cout<<"your i value : "<<i;
  getch();  */

  cout<<"\n\n Choose Contact No."<<i+1<<" ? (Y/N) : ";
  cin>>cho;
  if(cho=='y'||cho=='Y')
  {
    d+=1;
   selec[d]=i;
   cout<<"\n\\nthe selec[d] values update";
   cout<<"\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n";
   for(int e=0;e<=d;e+=1)
   cout<<"\nselec["<<e<<"] = "<<selec[e];

   //cout<<"\n\n the corresponding names are : "<<names[selec[d]];
   getch();
   //cout<<"\n\nthe selec value for "<<d<<" is"<<selec[d]<<"for i = "<<i;
   //getch();
  }

  cout<<"\n\n\\the selec[d] outside the if condition again to check....";
  for( e=0;e<=d;e+=1)
   cout<<"\nselec["<<e<<"] = "<<selec[e];
    getch();

}

 /*char sel[20];
 k=0;
 cout<<"\n\nSelect the names by alphabets seperated by commas : ";
 gets(sel);
 int selec[20];
 for(i=0;i<strlen(sel);i+=1)
 {
  if (sel[i]!=',')
  {
   selec[k++]=selec[i];
  }
 }
 for(i=0;i<=k;i+=1)
 puts(names[selec[i]]);
   */


 cout<<"\n\nnow the d value is : "<<d;
 getch();



 cout<<"\n\nthe selec[d] values are printed below\n\n";
 for(i=0;i<d+1;i+=1)
 {
  cout<<"selec["<<i<<"] = "<<selec[i]<<"\n";
 }
 getch();

 cout<<"\n\nAll the names are : ";
 for(i=0;i<k;i+=1)
 puts(names[i]);

 getch();


 cout<<"\n\nThe selected names are : ";
 for(i=0;i<d+1;i+=1)
 {
  cout<<"\n -- the selec[i] value is "<<selec[i];
  cout<<"\n\nso the names[selec[i]] value is names["<<selec[i]<<"] is : ";
  puts(names[selec[i]]);
  getch();
 }










}
Beispiel #5
0
void main(void)
{
    int code;
    int exit_code;
    int argc;
    char **argv;
    char dformat[64], ddevice[32];
    SInt32        response;

    /* Initialize operating environment */
#if TARGET_API_MAC_CARBON
    MoreMasterPointers(224);
#else
    MoreMasters();
#endif
    InitCursor();
    FlushEvents(everyEvent,0);

    if (AEInstallEventHandler(kCoreEventClass,kAEQuitApplication,
                              NewAEEventHandlerUPP((AEEventHandlerProcPtr) quitAppEventHandler),
                              0L,false) != noErr)
        ExitToShell();

        gActionFunctionScrollUPP = NewControlActionUPP(&actionFunctionScroll);

    Gestalt(gestaltMenuMgrAttr,&response);
    if(response & gestaltMenuMgrAquaLayoutMask)
                gRunningOnX = true;

    /* Initialize SIOUX */
    SIOUXSettings.initializeTB = false;
    SIOUXSettings.standalone = false;
    SIOUXSettings.asktosaveonclose = false;
    SIOUXSettings.sleep = GetCaretTime();
    SIOUXSettings.userwindowtitle = "\pGhostscript";

    /* Get arguments from user */
    argc = ccommand(&argv);

    /* Show command line window */
    if (InstallConsole(0))
        ExitToShell();

    /* Part of fudge to make SIOUX accept characters without becoming modal */
    SelectWindow(SIOUXTextWindow->window);
    PostEvent(keyDown, 0x4c00);  // Enter
    ReadCharsFromConsole(dformat, 0x7FFF);
    clrscr();

    /* Add in the display format as the first command line argument */
    if (argc >= MAX_ARGS - 1)
    {
       printf("Too many command line arguments\n");
       return;
    }

    memmove(&argv[3], &argv[1], (argc-1) * sizeof(char**));
    argc += 2;
    argv[1] = ddevice;
    argv[2] = dformat;

    gs_sprintf(ddevice, "-sDEVICE=display");
    gs_sprintf(dformat, "-dDisplayFormat=%d", display_format);

    /* Run Ghostscript */
    if (gsapi_new_instance(&instance, NULL) < 0)
    {
       printf("Can't create Ghostscript instance\n");
       return;
    }

#ifdef DEBUG
    visual_tracer_init();
    set_visual_tracer(&visual_tracer);
#endif

    gsapi_set_stdio(instance, gsdll_stdin, gsdll_stdout, gsdll_stderr);
    gsapi_set_poll(instance, gsdll_poll);
    gsapi_set_display_callback(instance, &display);

    code = gsapi_init_with_args(instance, argc, argv);
    if (code == 0)
       code = gsapi_run_string(instance, start_string, 0, &exit_code);
    else
    {
       printf("Failed to initialize. Error %d.\n", code);
       fflush(stdout);
    }
    code = gsapi_exit(instance);
    if (code != 0)
    {
       printf("Failed to terminate. Error %d.\n", code);
       fflush(stdout);
    }

    gsapi_delete_instance(instance);

#ifdef DEBUG
    visual_tracer_close();
#endif

    /* Ghostscript has finished - let user see output before quitting */
    WriteCharsToConsole("\r[Finished - hit any key to quit]", 33);
    fflush(stdout);

    /* Process events until a key is hit or user quits from menu */
    while(!gDone)
    {
        EventRecord eventStructure;

        if(WaitNextEvent(everyEvent,&eventStructure,SIOUXSettings.sleep,NULL))
        {
            if (eventStructure.what == keyDown)
            gDone = true;

            doEvents(&eventStructure);
        }
        else
            SIOUXHandleOneEvent(&eventStructure);
    }
}
Beispiel #6
0
void main(){clrscr();
rectangle_box(1, 1, 77, 24);
getch();}
Beispiel #7
0
//***************************************************
// function to get time duration from user
//***************************************************
void get_user_time(void)
{
  U8 uc_lcd_data_user_time[30] = {"Enter Time: "};
  U8 uc_lcd_data_user_temp[30] = {"Enter Temp: "};
  U8 sc_set_time_count = 0;
  U8 uc_set_temp_count = 0;

  clrscr();
  lcd_line1_disp(&uc_lcd_data_user_time[0],0);
  lcd_line1_disp(&Uc_set_user_time[0],12);
 
  while(sc_set_time_count < 8)					 //uc_set_time_count < 9
  {
  	wdt_feed(0x03ffffff);
	Uc_key_temp = get_key(1);
	pwm5_pulse_width(5000, 100);
	//pwm_enable();

	if((Uc_key_temp <= '9')&(Uc_key_temp >= '0'))
	{
		if(sc_set_time_count == 0)
		{
			
			if(Uc_key_temp < '3')
			{
				Uc_set_user_time[sc_set_time_count] = Uc_key_temp;
				sc_set_time_count += 1;
			}
		}
		else if(sc_set_time_count == 1)
		{
		   if((Uc_set_user_time[0] - 0x30) == 2)
		   {
			if(Uc_key_temp < '4')
			{
				Uc_set_user_time[sc_set_time_count] = Uc_key_temp;
				sc_set_time_count += 2;
			}
		   }
		   else
		   {
		   		Uc_set_user_time[sc_set_time_count] = Uc_key_temp;
				sc_set_time_count += 2;
		   }
		}
		else if(sc_set_time_count == 3)
		{
			
		  	if(Uc_key_temp < '6')
			{
				Uc_set_user_time[sc_set_time_count] = Uc_key_temp;
				sc_set_time_count += 1;
			}
		}
		else if(sc_set_time_count == 4)
		{
		 	
			Uc_set_user_time[sc_set_time_count] = Uc_key_temp;
			sc_set_time_count += 2;
			
		}
		else if(sc_set_time_count == 6)
		{
		  	
			if(Uc_key_temp < '6')
			{
				Uc_set_user_time[sc_set_time_count] = Uc_key_temp;
				sc_set_time_count += 1;
			}
		}
		else if(sc_set_time_count == 7)
		{
		  	
			if(Uc_key_temp < 'A')
			{
				Uc_set_user_time[sc_set_time_count] = Uc_key_temp;
				sc_set_time_count += 1;
			}
		}

	}

	if(Uc_key_temp == 'A')
	{	  	
		  lcd_line2_disp(&uc_lcd_data_user_temp[0],0);
		  lcd_line2_disp(&Uc_set_temp[0],12);
		  sc_set_time_count = 8;
		  uc_set_temp_count	= 3;
	}
	//*********************************************//
  
  	if(sc_set_time_count == 0)
	{
		lcd_line4_disp("Range 0-2",11);
	}
	if(sc_set_time_count == 1)
	{
		lcd_line4_disp("Range 0-3",11);
	}
	if(sc_set_time_count == 3)
	{
		lcd_line4_disp("Range 0-5",11);
	}
	if(sc_set_time_count == 4)
	{
		lcd_line4_disp("Range 0-9",11);
	}
	if(sc_set_time_count == 6)
	{
		lcd_line4_disp("Range 0-5",11);
	}
	if(sc_set_time_count == 7)
	{
		lcd_line4_disp("Range 0-9",11);
	}
	//*********************************************//
	lcd_line1_ch_disp(' ',((sc_set_time_count+12)-1));
	//Uc_set_user_time[sc_set_time_count + 1] = '\0';
	key_delay(250);		// do not remove it
	lcd_line1_disp(&Uc_set_user_time[0],12);
	pwm_disable();
  }
  

//---------------------------------------------------------------------------------
//------------------------------get temp from User---------------------------------
//---------------------------------------------------------------------------------
  lcd_line2_disp(&uc_lcd_data_user_temp[0],0);
  while(uc_set_temp_count < 3)
  {
  	wdt_feed(0x03ffffff);
	Uc_key_temp = get_key(1);
	
	pwm5_pulse_width(5000, 100);

	if((Uc_key_temp <= '9')&(Uc_key_temp >= '0'))
	{
		 if(uc_set_temp_count == 0)
		 {
		 	if(Uc_key_temp <= '3')
			{
				Uc_set_temp[uc_set_temp_count] =  Uc_key_temp;
		 		uc_set_temp_count++; 

			}
		 }
		 else 
		 {
		 		Uc_set_temp[uc_set_temp_count] =  Uc_key_temp;
		 		uc_set_temp_count++; 

		 }

	}
	if(Uc_key_temp == 'A')
	{
		 uc_set_temp_count = 3;
	}
	lcd_line2_disp(&Uc_set_temp[0],12);
	key_delay(250);		// do not remove it
	//*************range of no*****************//
	if(uc_set_temp_count == 0)
	{
		lcd_line4_disp("Range 0-3",11);
	}
	if(uc_set_temp_count == 1)
	{
		lcd_line4_disp("Range 0-9",11);
	}
	if(uc_set_temp_count == 2)
	{
		lcd_line4_disp("Range 0-9",11);
	}
	//****************************************//
	pwm_disable();
  }	
  
  lcd_line4_disp("Press Start",9);															 
  while((Uc_key_temp = get_key(1)) != 'D');
  Uc_alrm = 3;
  user_time_conv();	  // to convert the time entered by USER
  user_temp_conv();	  // to convert the temp entered by USER

  clrscr();
  default_page();    // Displaying default PAGE while leaving from USER MODE.
}
void add_reservation(FILE *reguPtr, FILE *reroPtr)
{
   int available, response;
	struct room rooms = { 0, 0, 0.00, 0, 0}; /* default room information*/
   struct reserve guest = {"", "", "", "", 0, "", 0,0.00, 0}; /* default reserve information*/
   clrscr();
   printf("\t\t\tadd_reservation\n\n\n");

   printf("\nEnter last name: "); fflush(stdin); gets(guest.text);
   sscanf(guest.text,"%s",guest.last_name); /* NOTE: no & */

   printf("If this incorrect press \"Y\" (Any key continue)");
   response = getch();

   while (response == 'Y' || response == 'y'){
   	printf("\nEnter last name: ");
   	gets(guest.text);
   	sscanf(guest.text,"%s",guest.last_name);	/* NOTE: no & */

   	printf("If this incorrect press \"Y\" (Any key continue)");
   	response = getch();
   }

   printf("\n\nGuest Mr\\Ms %s. \nEnter first name: ",guest.last_name);
   gets(guest.text);
   sscanf(guest.text,"%s",guest.first_name);	/* NOTE: no & */
   printf("If this incorrect press \"Y\" (Any key continue)");
 	response = getch();

   while (response == 'Y' || response == 'y'){
		printf("\nGuest Mr\\Ms %s. \nEnter first name: ",guest.last_name);
   	gets(guest.text);
   	sscanf(guest.text,"%s",guest.first_name);	/* NOTE: no & */

   	printf("If this incorrect press \"Y\" (Any key continue)");
   	response = getch();
   }

   /* ------ Add the names together ------ */
   strcpy(guest.full_name,guest.first_name);	/* First copy the first	*/
   strcat(guest.full_name," ");		/* name then add a space*/
   strcat(guest.full_name,guest.last_name);	/* and last name.	*/

   /* ------ Some display using puts() ------ */

   printf("\n\n");
   printf("\t================================\n");
   printf("\t\t%s\n",guest.full_name);
   printf("\t================================");
   printf("\n");

   printf("Enter length-of-stay(Days): ");
   scanf("%d", &guest.lenght_of_stay);
   fflush(stdin);  /* flush the input stream in case of bad input */

   printf("Enter credit card number: ");
   scanf("%d", &guest.credit_card_num);
   fflush(stdin);  /* flush the input stream in case of bad input */

   printf("Please choose room type -: \n"
   		 "\t0. Smoking\n"
     		 "\t1. Non-Smoking\n"
     	 	 "Option: ");
   scanf("%d", &guest.prefered_room_type);
   fflush(stdin);  /* flush the input stream in case of bad input */

   while (guest.prefered_room_type != 0 && guest.prefered_room_type != 1){
   	printf("\n\aWrong Input!!!\n\n");
   	printf("Please choose room type -: \n"
   		    "\t0. Smoking\n"
     		    "\t1. Non-Smoking\n"
     		    "Option: ");
		scanf("%d", &guest.prefered_room_type);
      fflush(stdin);  /* flush the input stream in case of bad input */
   }

   if (guest.prefered_room_type == 0 || guest.prefered_room_type == 1){
      available = 0;
   	while ( (!feof(reroPtr)) && (available == 0) ){
      	fread(&rooms, sizeof(struct room), 1, reroPtr);
   		if ( (rooms.room_type == guest.prefered_room_type) && (rooms.status == 0) ){

     			available = 1;
            printf("\nRoom #%d was found. Do you want to reserve this room? (Y\\N)", rooms.room_num);
            response = getch();
				if ((response == 'n') || (response == 'N')) {
					available = 0; // allow user to move on & see the next room
      		}
            else{
					rooms.status = 2; /* change room status to reserved  */
					guest.balance = rooms.cost;
               printf("\nRoom %d is reserved for you Mr\\Ms %c. %s", rooms.room_num, guest.first_name[0],guest.last_name);
               srand(time(NULL));
   				guest.guest_num = rand()% 1000 + 9000;
     				printf("\nYour Guest# is: %d", guest.guest_num);
      			rooms.guest_num = guest.guest_num;

           		printf("\n\nPlease wait while data is being stored!\n");
			     	Sleep(1000); printf(">>>>."); Sleep(1000); printf(">>>>."); Sleep(1000); printf(">>>>."); Sleep(1000);

					/* update the room information */
					fseek(reroPtr, (rooms.room_num - 1)*sizeof(struct room), SEEK_SET);
               fwrite(&rooms, sizeof(struct room), 1, reroPtr);
					/* update the guest information */
					fseek(reguPtr, (guest.guest_num - 1)*sizeof(struct reserve), SEEK_SET);
					fwrite(&guest, sizeof(struct reserve), 1, reguPtr);
               printf("\nSaved!");
				}
         }
   	}
   }
  	if (available == 0){
  		printf("\nI am sorry Mr\\Ms %c. %s",guest.first_name[0],guest.last_name);
  		printf("\nThe room is not available. You're not accepted!");
  	}
   Sleep(1000);
	rewind(reroPtr);
   rewind(reguPtr);
}/* end function newRecord*/
void cancel_reservation(FILE *reguPtr, FILE *reroPtr)
{
   int roomNum, response, found;
   char	holdtext[50], holdlast_name[50];
	struct room rooms = { 0, 0, 0.00, 0, 0}; /* default room information*/
   struct reserve guest = {"", "", "", "", 0, "", 0,0.00, 0}; /* default reserve information*/
   clrscr();
   printf("\t\t\tcancel_reservation\n\n\n");

   printf("Please enter details to query!\n\n");
   printf("Enter room number: ");
   scanf("%d", &roomNum);
   fseek(reroPtr, (roomNum - 1)*sizeof(struct room), SEEK_SET);
	fread(&rooms, sizeof(struct room), 1, reroPtr);

   if(rooms.room_num == 0){
   	printf("\nRoom #%d has no Information!!!", roomNum);
      Sleep(1000);
      rewind(reroPtr);
      return;
   }
   else {
   	   printf("\nEnter last name: "); fflush(stdin); gets(holdtext);
		   sscanf(holdtext,"%s",holdlast_name); /* NOTE: no & */

   		printf("If this incorrect press \"Y\" (Any key continue)");
   		response = getch();

   		while (response == 'Y' || response == 'y'){
   			printf("\nEnter last name: ");
   			gets(holdtext);
   			sscanf(holdtext,"%s",holdlast_name);	/* NOTE: no & */

   			printf("If this incorrect press \"Y\" (Any key continue)");
   			response = getch();
   		}
         found = 0;
         rewind(reguPtr);
         while ( (!feof(reguPtr)) && (found == 0) ) {
         	fread(&guest, sizeof(struct reserve), 1, reguPtr);
            if ((guest.last_name == holdlast_name) && (guest.guest_num == rooms.guest_num)){
               found = 1;

            	printf("\n\t\t Name Found\n "
            			 "\n\t\t Last name: %s"
                      "\n\t\t First name: %s"
                      "\n\t\t Full name: %s"
            			 "\n\t\t Length of stay: %d"
                      "\n\t Credit Card Number: %s",
                      guest.last_name, guest.first_name,
                      guest.full_name, guest.lenght_of_stay, guest.credit_card_num);

               if (guest.prefered_room_type == 0)
                   printf("\n\t\tRoom type: Smoking");

               if (guest.prefered_room_type == 1)
               	printf("\n\t\tRoom type: Non-Smoking");

               printf("\n\t\t Balance: %d"
                      "\n\t\t Guest's Number: %d",
                      guest.prefered_room_type, guest.balance, guest.guest_num);
            }
         }
         getch();
   }
}
Beispiel #10
0
void credits2(void)
{
    int i, ch;
    int p;
    int plast = -1;
    clrscr();

    centerprint(aa_imgwidth(context) / 2, aa_imgheight(context) / 3, 3, 128, "The", 0);
    centerprint(aa_imgwidth(context) / 2, 2 * aa_imgheight(context) / 3, 3, 128, "END", 0);
    drawptr = decrand;
    params->randomval = 50;
    timestuff(0, NULL, draw, 5000000);
    drawptr = NULL;
    params->randomval = 0;
    drawptr = pryc;
    timestuff(0, NULL, draw, MAXTIME);
    drawptr = NULL;
    clrscr();
    draw();
    load_song("bb3.s3m");
    bbupdate();
    starttime = endtime = TIME;
    play();
    bbwait(1);
    for (i = 0; i < LOGOHEIGHT; i++) {
	aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i, AA_BOLD, "8  8");
	if (i)
	    aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i - 1, AA_NORMAL, "8  8");
	bbflushwait(100000);
    }
    aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i - 1, AA_NORMAL, "8  8");

#define LWIDTH

    for (i = aa_scrwidth(context) / 2; i; i--) {
	display8();
	displaya(i);
	bbflushwait(10000);
    }
    for (; i < 100; i++) {
	textclrscr();
	displaya(10 * sin(i * M_PI / 100));
	display8();
	bbflushwait(10000);
    }
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_DIM, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_NORMAL, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_BOLD, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_NORMAL, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    bbwait(1000000);
    for (i = LOGOY; i > 1; i--) {
	textclrscr();
	displogo(i);
	bbflushwait(30000);
    }

    source = malloc(aa_imgwidth(context) * (aa_imgheight(context)));
    target = malloc(aa_imgwidth(context) * (aa_imgheight(context)));
    params->dither = AA_NONE;
    format(dual ? aa_scrwidth(context) / 2 : aa_scrwidth(context));
    p = 0;
    while (1) {
	if (p != plast) {
	    getsource();
	    displaytext(p);
	    gettarget();
	    morph();
	    displaytext(p);
	    aa_flush(context);
        emscripten_sleep(1);
	    plast = p;
	}
      again:
    emscripten_sleep(100);
#ifndef __DJGPP__
	//ch = aa_getkey(context, 100);
    ch = AA_NONE;
#else
	while ((ch = bbupdate()) == AA_NONE) ;
#endif

	switch (ch) {
	case '1':
	    load_song("bb.s3m");
	    bbupdate();
	    play();
	    break;
	case '2':
	    load_song("bb2.s3m");
	    bbupdate();
	    play();
	    break;
	case '3':
	    load_song("bb3.s3m");
	    bbupdate();
	    play();
	    break;

	case 'b':
	case 'k':
	case 'B':
	case 'K':
	case AA_BACKSPACE:
	case AA_UP:
	    p -= (aa_scrheight(context) - YSTART) / 2 * (dual + 1);
	    if (p < 0)
		p = 0;
	    break;
	case AA_DOWN:
	case AA_LEFT:
	case 'f':
	case 'F':
	case ' ':
	case 'j':
	case 'J':
	    p += (aa_scrheight(context) - YSTART) / 2 * (dual + 1);
	    if (p > textsize)
		p = textsize;
	    break;
	case 'q':
	case 'Q':
	case AA_ESC:
	    finish_stuff = 0;
	    backconvert(0, 0, aa_scrwidth(context), aa_scrheight(context));
	    bbupdate();
	    starttime = endtime = TIME;
	    drawptr = decbright;
	    timestuff(0, NULL, draw, 1000000);
	    textclrscr();
	    drawptr = NULL;
	    aa_flush(context);
        emscripten_sleep(1);
	    free(source);
	    free(target);
	    return;
	default:
	    goto again;
	}
	bbupdate();
	starttime = endtime = TIME;
    }
}
void add_room_info(FILE *reroPtr)
{
   int roomNum, response;
   struct room rooms = {0,0,0.00,0,0}; /* default information*/
   clrscr();
   printf("\t\t\tadd_room_info\n\n\n");

	printf("Enter room number(1 - 50): ");
	scanf("%d",&roomNum);
  	while (roomNum < 1 || roomNum > 50){
     	clrscr();
     	printf("\t\t\tadd_room_info\n\n\n");
     	printf("\aWrong Input!!!\n\n");
  		printf("Enter room number(1 - 50): ");
		scanf("%d",&roomNum);
  	}
	fseek(reroPtr,(roomNum-1)*sizeof(struct room),SEEK_SET);
	fread(&rooms,sizeof(struct room),1,reroPtr);

	if (rooms.room_num != 0){
  		printf("Room information already exist...");
     	Sleep(1000);
     	rewind(reroPtr);
      return;
  	}
  	else {
		printf("Room Type (Smoking \"0\" or Non-Smoking \"1\"): ");
		scanf("%d", &rooms.room_type);

		while (rooms.room_type != 0 && rooms.room_type != 1){
			printf("\n\aWrong Input!!!\n\n");
			printf("Room Type (Smoking \"0\" or Non-Smoking \"1\"): ");
			scanf("%d", &rooms.room_type);
		}/* end while*/
		if (rooms.room_type == 0){
			rooms.cost = 4000;
			printf("Room Cost: $%.2f\n", rooms.cost);
		}/* end if*/
		else{
			rooms.cost = 3000;
			printf("Room Cost: $%.2f\n", rooms.cost);
		}/* end else*/

		printf("Status (Available \"0\", Occupied \"1\", Rerserved \"2\"): ");
		scanf("%d", &rooms.status);
		while (rooms.status != 0 && rooms.status != 1 && rooms.status != 2){
			printf("\n\aWrong Input!!!\n\n");
			printf("Status (Available \"0\", Occupied \"1\", Rerserved \"2\"): ");
			scanf("%d", &rooms.status);
		}/* end while*/

    	printf("\nStill add this room? (Y\\N)");
     	response = getch();

		if ((response == 'N') || (response == 'n')) {
  			printf("\nDisregarding Input..."); Sleep(1000); printf("Discarded!");
        	Sleep(1000);
        	rewind(reroPtr);
         return;
  		}

     	rooms.room_num = roomNum;
      rooms.guest_num = 0; /* set room guest number to zero because it' available*/

		printf("\n\nPlease wait while data is being stored!\n");
     	Sleep(1000); printf(">>>>."); Sleep(1000); printf(">>>>."); Sleep(1000); printf(">>>>."); Sleep(1000);
     	/* Write data to file*/
   	//##################################################################################################################
     	fseek(reroPtr, (rooms.room_num - 1)*sizeof(struct room), SEEK_SET);
      fwrite(&rooms, sizeof(struct room), 1, reroPtr);
     	rewind(reroPtr);
      //##################################################################################################################
  		printf("\nSaved!");
     	Sleep(1000);
  	}
}
Beispiel #12
0
int main (void)
#endif
{
    struct mouse_info info;
    struct mouse_box full_box, small_box;
    unsigned char width, height;
    char C;
    bool Invisible = true, Done = false, Jailed = false;

    /* Initialize the debugger */
    DbgInit (0);

    /* Set dark-on-light colors.  Clear the screen. */
#ifdef __CBM__
    (void) bordercolor (COLOR_GRAY2);
    (void) bgcolor (COLOR_WHITE);
    (void) textcolor (COLOR_GRAY1);
#else
    (void) bordercolor (COLOR_BLUE);
    (void) bgcolor (COLOR_WHITE);
    (void) textcolor (COLOR_BLACK);
#endif
    cursor (0);
    clrscr ();

    /* If a lightpen driver is installed, then it can get a calibration value
    ** from this file (if it exists).  Or, the user can adjust the pen; and,
    ** the value will be put into this file, for the next time.
    ** (Other drivers will ignore this.)
    */
#if defined(__C64__) || defined(__C128__) || defined(__CBM510__)
    pen_adjust ("pen.dat");
#endif

#if DYN_DRV
    /* If a dynamically loadable driver is named on the command line,
    ** then use that driver instead of the standard one.
    */
    if (argc > 1) {
        mouse_name = argv[1];
    } else {
        /* Output a warning about the standard driver that is needed. */
        DoWarning ();
        mouse_name = mouse_stddrv;
    }

    /* Load and install the driver. */
    CheckError ("mouse_load_driver",
                mouse_load_driver (&mouse_def_callbacks, mouse_name));
#else
    /* Install the driver. */
    CheckError ("mouse_install",
                mouse_install (&mouse_def_callbacks,
#  ifdef MOUSE_DRIVER
                               MOUSE_DRIVER
#  else
                               mouse_static_stddrv
#  endif
                               ));
#endif

    /* Get the initial bounding box. */
    mouse_getbox (&full_box);

    screensize (&width, &height);

top:
    clrscr ();

    /* Print a help line */
    cputs (" d)ebug  h)ide   q)uit   s)how   j)ail");

    /* Put a cross at the center of the screen. */
    gotoxy (width / 2 - 3, height / 2 - 1);
#if defined(__CBM__)
    cprintf ("%3u,%3u\r\n%*s\xDB", width / 2 * 8 + 4, height / 2 * 8 + 4,
             width / 2, "");
#else
    cprintf ("%3u,%3u\r\n%*s+", width / 2 * 8 + 4, height / 2 * 8 + 4,
             width / 2, "");
#endif

    /* Test loop */
    ShowState (Jailed, Invisible);
    do {
        /* Get the current co-ordinates and button states; and, print them. */
        mouse_info (&info);
        gotoxy (0, 2);
        cprintf (" X  = %3d\r\n", info.pos.x);
        cprintf (" Y  = %3d\r\n", info.pos.y);
        cprintf (" B1 = %c\r\n", (info.buttons & MOUSE_BTN_LEFT) ?
#ifdef __CBM__
                 0x5F
#else
                 'v'
#endif
                 : '^');
        cprintf (" B2 = %c", (info.buttons & MOUSE_BTN_RIGHT) ?
#ifdef __CBM__
                 0x5F
#else
                 'v'
#endif
                 : '^');

        /* Handle user input */
        if (kbhit ()) {
            cclearxy (1, 9, 23);
            switch (tolower (C = cgetc ())) {
                case 'd':
                    BREAK();

                    /* The debugger might have changed the colors.
                    ** Restore them.
                    */
#ifdef __CBM__
                    (void) bordercolor (COLOR_GRAY2);
                    (void) bgcolor (COLOR_WHITE);
                    (void) textcolor (COLOR_GRAY1);
#else
                    (void) bordercolor (COLOR_BLUE);
                    (void) bgcolor (COLOR_WHITE);
                    (void) textcolor (COLOR_BLACK);
#endif

                    /* The debugger changed the screen; restore it. */
                    goto top;

                case 'h':
                    mouse_hide ();
                    ShowState (Jailed, ++Invisible);
                    break;

                case 'j':
                    if (Jailed) {
                        mouse_setbox (&full_box);
                        Jailed = false;
                    } else {
                        small_box.minx = max (info.pos.x - 10, full_box.minx);
                        small_box.miny = max (info.pos.y - 10, full_box.miny);
                        small_box.maxx = min (info.pos.x + 10, full_box.maxx);
                        small_box.maxy = min (info.pos.y + 10, full_box.maxy);
                        mouse_setbox (&small_box);
                        Jailed = true;
                    }
                    ShowState (Jailed, Invisible);
                    break;

                case 's':
                    mouse_show ();
                    if (Invisible) {
                        ShowState (Jailed, --Invisible);
                    }
                    break;

                case 'q':
                    Done = true;
                    break;

                default:
                    gotoxy (1, 9);
                    cprintf ("Spurious character: $%02X", C);
            }
        }
    } while (!Done);

#if DYN_DRV
    /* Uninstall and unload the driver. */
    CheckError ("mouse_unload", mouse_unload ());
#else
    /* Uninstall the static driver. */
    CheckError ("mouse_uninstall", mouse_uninstall ());
#endif

    /* Say goodbye */
    cputsxy (0, height / 2 + 3, "Goodbye!");
    return EXIT_SUCCESS;
}
Beispiel #13
0
int file_selector(char *result) {
//	SDL_Event ev;
    u32 keys; 
	int picked = 0;
//	int max_width = tiawidth/FONT_WIDTH;
	int max_height = MaxLines/FONT_HEIGHT; //-1;
	int k = 0;

	if (PaletteNumber != UserPaletteNumber)
	{
		PaletteNumber = UserPaletteNumber;
		gui_SetVideoMode();
	}
	clrscr();

	/* filesread is a global that gets updated by get_list */
	if (first_filelist) 
	{
		get_file_list();
		first_filelist = 0;
	}

	while(hidKeysHeld()) hidScanInput(); //wait for previous keys to be released

	while(!picked) {
		int action;

		window_line = draw_file_list(curfile, window_line, max_height-2);
//		SDL_WaitEvent(&ev);	
		hidScanInput();
		while(!hidKeysHeld()) hidScanInput();
		keys = hidKeysHeld();
		
		action = gui_navigation(keys); //&ev);

		if(action == GUI_NO_ACTION)
			continue;

		switch(action) 
		{
		char type;

		case GUI_EXIT_GUI:
			clrscr();
			return 0; /* abort */

		case GUI_ACTIVATE_SEC:
			match = 0;
			curfile++;
			if(curfile == filesread) curfile = 0;
			clrscr();
			type = file_list[curfile][strlen(file_list[curfile])-1];
			if(type == '/')	/* if it's a dir, cd to it and get new file list. */
			{
				if (chdir(file_list[curfile]) == 0)
				{
					curfile = 0;
					get_file_list();
				}
			} 
			else		/* if it's a file, return it */
			{
				strcpy(result, file_list[curfile]);
				picked = 1;
			}
			break;
		
		
		case GUI_ACTIVATE_PRI:
			match = 0;
			clrscr();
			type = file_list[curfile][strlen(file_list[curfile])-1];
			if(type == '/')	/* if it's a dir, cd to it and get new file list. */
			{
				if (chdir(file_list[curfile]) == 0)
				{
					curfile = 0;
					get_file_list();
				}
			} 
			else		/* if it's a file, return it */
			{
				strcpy(result, file_list[curfile]);
				picked = 1;
			}
			break;

		case GUI_UP:
			match = 0;
			curfile--;
			if(curfile < 0) curfile = filesread - 1;
			break;

		case GUI_DOWN:
			match = 0;
			curfile++;
			if(curfile == filesread) curfile = 0;
			break;

		case GUI_PAGEDOWN:
			match = 0;
			if(filesread > max_height-1) {
				curfile += max_height-1;
				if(curfile >= filesread)
					curfile = 0;
				window_line = curfile;
				clrscr();
			}
			break;

		case GUI_PAGEUP:
			match = 0;
			if(filesread > max_height-1) {
				curfile -= max_height-1;
				if(curfile < 0)
					curfile = filesread-1;
				window_line = curfile;
				clrscr();
				break;
			}

		case GUI_HOME:
			match = 0;
			curfile = 0;
			window_line = 0;
			clrscr();
			break;

		case GUI_END:
			match = 0;
			curfile = filesread-1;
			window_line = curfile;
			clrscr();
			break;
			
		case GUI_RANDOM:
			match = 0;
			curfile = rand() % filesread;
			window_line = curfile;
			type = file_list[curfile][strlen(file_list[curfile])-1];
			
			while (type == '/')	/* if it's a dir, find another file */
			{
				curfile = rand() % filesread;
				window_line = curfile;
				type = file_list[curfile][strlen(file_list[curfile])-1];
			} 
			
			
			
			clrscr();
			break;


		default:
//			if(ev.type == SDL_KEYDOWN)
//			if(keys)
//			{
//				k = ev.key.keysym.sym;
//				curfile = window_line = find_next_rom(curfile, keys); // !!!!!!
//			}
			break;
		}

		svcSleepThread (250000000);
//		SDL_WM_SetCaption(file_list[curfile], file_list[curfile]);

	}
	
	return picked;
}
Beispiel #14
0
void display_chars(int off,int off2,int places[25])
{
	int a,b,places_c,x=3,y=12;

	clrscr();
	display();

/* -----------------------------------------
	 Display loop
	 -----------------------------------------------------------------------*/
	for (places_c=0;places_c<=23;places_c++) {
		b=0;
		gotoxy(x,y);
		if  (y==12)
			  a=0;
		else a=1;
		if  (places[places_c]<0)
			  disp_o(a,places,places_c);
		if  (places[places_c]>0)
			  disp_x(a,places,places_c);

		if ((x==18 && y==3) || (x==45 && y==3)) {
			x-=3;
			b=2;
		}
		if (x==30 && y==12) {
			x+=3;
			b=2;
		}
		if (x!=18 && x!=45 && x!=30 && b!=2) {
			if (y==12)
				x+=3;
			if (y==3)
				x-=3;
			b=1;
		}
		if (x==18 && y==12 && !b)
			x+=12;
		if (x==45 && y==12 && !b)
			y=3;
		if (x==30 && y==3 && !b)
			x-=12;
	}

/* -----------------------------------------
	 Bar calculations
	 -----------------------------------------------------------------------*/
	if (places[24]!=0)
		bar_xo(places);

/* -----------------------------------------
	 Bear-off calculations
	 -----------------------------------------------------------------------*/
	if (off>0) {
		gotoxy(50,1);
		cout << "X-off = " << off;
	}
	if (off2>0) {
		gotoxy(50,3);
		cout << "O-off = " << off2;
	}
}
Beispiel #15
0
int main(int argc, char **argv)
{
    I16 card, err;
    U16 card_num;
    U16 GCtr;
    U16 Mode = x4_AB_Phase_Encoder;
    U16 SrcCtrl = 0; //Not used in encoder
    U16 PolCtrl = 0; //Not used in encoder
    U32 LReg1_Val = 0; //Not used in encoder
    U32 LReg2_Val = 0; //Not used in encoder
    U32 RD_Value;
    int i = 0;

    printf("This sample performs x4 AB phase mode.\n");
    printf("Card Number? ");
    scanf(" %hd", &card_num);

    card = Register_Card(PCI_9222, card_num);
    if(card<0){
        printf("Register_Card Error: %d\n", card);
        exit(1);
    }

    printf("Encoder Number? ");
    scanf(" %hd", &GCtr);
    GCtr = (GCtr==1)? P922x_ENCODER1:P922x_ENCODER0;

    /*Clear Encoder*/
    err = GPTC_Clear(card, GCtr);
    if(err<0){
        printf("GPTC_Clear Error: %d\n", err);
        goto ERR_RET;
    }

    /*Setup Encoder*/
    err = GPTC_Setup(card, GCtr, Mode, SrcCtrl, PolCtrl, LReg1_Val, LReg2_Val);
    if(err<0){
        printf("GPTC_Setup Error: %d\n", err);
        goto ERR_RET;
    }

    /*Enable Encoder*/
    printf("Press any key to enable counter...\n");
    getch();
    err = GPTC_Control(card, GCtr, IntENABLE, 1);
    if(err<0){
        printf("GPTC_Control(IntENABLE) Error: %d\n", err);
        goto ERR_RET;
    }

    do{
        /*Read Encoder*/
        err = GPTC_Read(card, GCtr, &RD_Value);
        if(err<0){
            printf("GPTC_Read Error: %d\n", err);
            goto ERR_RET2;
        }
        clrscr();
        printf("/*---------------------------------*/\n");
        printf(" Encoder Number: %d\n", GCtr-4);
        printf(" Read Count: %d\n\n", RD_Value);
        printf("      You can press Enter to stop...\n");
        printf("/*---------------------------------*/\n");
        usleep(1000);
    }while(!kbhit());

ERR_RET2:
    GPTC_Control(card, GCtr, IntENABLE, 0);
ERR_RET:
    GPTC_Clear(card, GCtr);
    Release_Card(card);

    printf("\nPress any key to exit...\n");
    getch();
    return 0;
}
void report_smoke_nonsmoke(FILE *reroPtr)
{
	FILE *report1;  /* Create file report of available smoking and
   						non-smoking rooms for printing */
   int found;
   struct room rooms = { 0, 0, 0.00, 0, 0}; /* default room information*/
   clrscr();
   printf("\t\t\treport_smoke_nonsmoke\n\n\n");

   if( (report1 = fopen("Available Smoking and Non-smoking rooms.txt", "w") ) ==
   	NULL){
   	printf("\aRoom file could not be found.\n\n"
      		 "Press any to EXIT!");
      getch();
   }
   else {
   							/*Print to screen*/
      printf("NB: Room Type (Smoking \"0\" or Non-Smoking \"1\")\n"
      		 "    Room Status (Available \"0\", Occupied \"1\", Rerserved \"2\")\n"
             "    Room Guest Number \"0\", No guest, hence equal zero.\n\n\n");
                       /*Write to file*/
      fprintf(report1,"%s\n%s\n%s\n\n\n","NB: Room Type (Smoking \"0\" or Non-Smoking \"1\")",
      		 "    Room Status (Available \"0\", Occupied \"1\", Rerserved \"2\")",
             "    Room Guest Number \"0\", No guest, hence equal zero.");
                        /*Print to screen*/
      printf("%-12s%-2s%-10s%-2s%-10s%-2s%-12s%-2s%-17s\n",
            		"Room Number","|","Room Type","|","Room Cost","|","Room Status","|","Room Guest Number");
                        /*Write to file*/
      fprintf(report1,"%-12s%-2s%-10s%-2s%-10s%-2s%-12s%-2s%-17s\n",
            		"Room Number","|","Room Type","|","Room Cost","|","Room Status","|","Room Guest Number");
      found = 0;
      rewind(reroPtr);
   	while ( (!feof(reroPtr)) && (found == 0) ){
      	fread(&rooms, sizeof(struct room), 1, reroPtr);
         if ((rooms.room_num > 0) && (rooms.status == 0)){
                       /*Print to screen*/
         	printf("%-12d%-12s%-12s%-14s%-19s\n",rooms.room_num, rooms.room_type, rooms.cost,
   				rooms.status, rooms.guest_num);
                       /*Write to file*/
         	fprintf(report1,"%-12d%-12s%-12s%-14s%-19s\n",rooms.room_num, rooms.room_type, rooms.cost,
   				rooms.status, rooms.guest_num);
            found = 1;
         }
      }
      if(found == 0) {
   		printf("\n\n\n\aNo Rooms are Available!");
         fprintf(report1,"\n\n\n%s","No Rooms are Available!");
         Sleep(1000);
      }
      else {
      	printf("\n\nPlease wait while data is being stored to report file!\n");
			Sleep(1000); printf(">>>>."); Sleep(1000); printf(">>>>."); Sleep(1000); printf(">>>>."); Sleep(1000);
         printf("Stored!\n\nData is stored in a file called \"Available Smoking and Non-smoking rooms\"");

         printf("\nPress Any Key...Main Menu!");
         getch();
      }

   }
   fclose(report1);
}
Beispiel #17
0
void main()
{
	clrscr();
	int s_on=1,speed=50,quit=0,s,p2y=12,ballx=11,bally=3,p1y=12,bxdir=1,bydir=1,p2dir=0,p1dir=0, p2score=0,p1score=0;
	char choice;
	gotoxy(30,12);
	cout << "Chops's Pong";
	getch();
	help();
	clrscr();
	do
	{
		do
		{
		// Write scores
		gotoxy(1,1);
		cout << p2score;
		gotoxy(75,1);
		cout << p1score;



		//clear paddle
		gotoxy(10,p2y+0); cout << " ";
		gotoxy(10,p2y+1); cout << " ";
		gotoxy(10,p2y+2); cout << " ";
		gotoxy(10,p2y+3); cout << " ";

		gotoxy(70,p1y+0); cout << " ";
		gotoxy(70,p1y+1); cout << " ";
		gotoxy(70,p1y+2); cout << " ";
		gotoxy(70,p1y+3); cout << " ";
		// Draw 2p paddle
		if(p2y==21 || p2y==1) p2dir=0;
		if(p1y==21 || p1y==1) p1dir=0;
		if(p2dir==1)
		{
			p2y++;
			if(p2y>=21) p2y=20;
		}
		if(p2dir==-1)
		{
			p2y--;
			if(p2y<=1) p2y=2;
		}
		if(p1dir==1)
		{
			p1y++;
			if(p1y>=21) p1y=20;
		}
		if(p1dir==-1)
		{
			p1y--;
			if(p1y<=1) p1y=2;
		}
		gotoxy(10,p2y+0); cout << "л";
		gotoxy(10,p2y+1); cout << "л";
		gotoxy(10,p2y+2); cout << "л";
		gotoxy(10,p2y+3); cout << "л";

		// Draw p1 paddle
		gotoxy(70,p1y+0); cout << "л";
		gotoxy(70,p1y+1); cout << "л";
		gotoxy(70,p1y+2); cout << "л";
		gotoxy(70,p1y+3); cout << "л";

		// Draw Ball
		gotoxy(ballx,bally);
		cout << "лл";
		delay(speed);
		nosound();
		gotoxy(ballx,bally);
		cout << "  ";


		//Changing ball coords
		if(bxdir==1) ballx=ballx+2;
		if(bxdir==0) ballx=ballx-2;
		if(bydir==1) bally++;
		if(bydir==0) bally--;
		if(ballx<=1)
		{
			p1score++;
			speed=50;
			if(s_on==1)
			{
				for(s=1000;s>500;s--)
				{
					sound(s);
					delay(3);
				}
			}
			nosound();

			getch();
			if(p1score==5)
			{
				clrscr();

				do
				{
					gotoxy(30,11);
					cout << "Right Player Wins ";
					if(p2score==0) cout << "With a Shutout";
					gotoxy(30,12);
					cout << "Game over";
					gotoxy(30,13);
					cout << "Play Again? Y/N";
					choice=getch();
					choice=toupper(choice);
					if(choice=='Y') main();
					if(choice=='N') exit(1);
				}
				while(quit!=1);
			}
			ballx=11;
			bally=3;
			bxdir=1;
			bydir=1;
		}
		if(ballx>=79)
		{

			p2score++;
			speed=50;
			if(s_on==1)
			{
				for(s=1000;s>500;s--)
				{
					sound(s);
					delay(3);
				}
			}
			nosound();
			if(p2score==5)
			{
				clrscr();

				do
				{
					gotoxy(30,11);
					cout << "Right Player Wins ";
					if(p1score==0) cout << "With a Shutout";
					gotoxy(30,12);
					cout << "Game over";
					gotoxy(30,13);
					cout << "Play Again? Y/N";
					choice=getch();
					choice=toupper(choice);
					if(choice=='Y') main();
					if(choice=='N') exit(1);
				}
				while(quit!=1);


			}
			getch();
			ballx=11;
			bally=3;
			bxdir=1;
			bydir=1;

		}
		if(ballx==11 && bally>p2y-2 && bally <p2y+5)
		{
			bxdir=1;
			if(bally<=p2y) bydir=0;
			if(bally>=p2y+3) bydir=1;

			if(s_on==1) sound(500);
		}
		if(ballx==69 && bally>p1y-2 && bally <p1y+5)
		{
			bxdir=0;
			if(s_on==1) sound(500);
			if(bally<=p1y)
			{
				bydir=0;
				speed=speed-5;
			}
			if(bally>=p1y+3)
			{
				bydir=1;
				speed=speed-5;
			}
		}
		if(bally<=1)
		{
			bydir=1;
			bally=1;
			if(s_on==1)sound(1000);
		}
		if(bally>=24)
		{
			bydir=0;
			bally=24;
			if(s_on==1) sound(1000);
		}

		}
		while(bioskey(1)==0);
		choice=getch();
		choice=toupper(choice);
		switch(choice)
		{
			case('Q'):
			{
				quit=1;
				break;
			}
			case('8'):
			{
				p1dir=-1;
				break;
			}
			case('5'):
			{
				p1dir=1;
				break;
			}
			case('A'):
			{
				p2dir=-1;
				break;
			}
			case('Z'):
			{
				p2dir=1;
				break;
			}
			case('P'):
			{
				gotoxy(ballx,bally);
				cout << "Paused";
				getch();
				gotoxy(ballx,bally);
				cout << "      ";
			}
			case('H'):
			{
				help();
			}
			case('S'):
			{
				if(!s_on) s_on=1;
				if(s_on) s_on=0;
			}


		}


	}
	while(!quit);
	clrscr();
}
void main()
{
  int i,choice,no,r,last=0;
  int Stack[20],b=0;
  clrscr();

   do
   {
    printf("\n1> FOR PUSH INTO STACK");
    printf("\n2> FOR POP FROM STACK");
    printf("\n3> FOR EXIT FROM MENU");
    printf("\nENTER YOUR CHOICE:");
    scanf("%d",&choice);

    switch(choice)
    {
      case 1:printf("\nEnter Number:");
	     scanf("%d",&no);
	     if(no>9)
	     { printf("\n-->YOU HAVE ENTER NUMBER BETWEEN (0- 9):");}

	     else if(no>=last+2 || no<=last)
	     {
	       if(no==0)
	       {
				push(no);
	       }
	       else
	       {
				printf("\nLAST PUSHED NUMBER:%d",last);
				printf("\nPLESE PUSH NUMBER IN PROPER SEQUENCE\n");
	       }
	     }
	     else
	     {
		    last=no;
		    push(no);
	     }
	     break;

       case 2: r=pop();
				if(r!=-1)
				{
					Stack[b++]=r;
					printf("\nPOP element from stack:%d",r);
				}
				printf("\nElement in Stack:");
				for(i=0;i<b;i++)
				{
						printf("%d ",Stack[i]);
				}
				printf("\n");
				break;

      case 3: exit(0);
				break;

     default:printf("\n Please Enter Proper Choice");
    }
   }while(choice!=3);
   getch();
}
Beispiel #19
0
void main()
{

	int i,j,k,choice,data,prevdata;
	char ch;
	struct node *first=NULL,*last;
	clrscr();
	printf("\n1 Append");
	printf("\n2 Insert after...");
	printf("\n3 Insert before...");
	printf("\n4 Insert beginning");
	printf("\n5 Delete");
	printf("\n6 Count");
	printf("\n7 reverse");
	printf("\n0 Exit");
	do
	{
	 printf("\nEnter choice:");
	 scanf("%d",&choice);
	 switch(choice)
	 {
		case 1:
		printf("\nEnter the value to be appended:");
		scanf("%d",&data);
		append(&first,data);
		display(first);
		break;
		case 2:
		printf("\nEnter the value to be inserted");
		scanf("%d",&data);
		printf("\nEnter the value to be inserted after:");
		scanf("%d",&prevdata);
		inafter(first,data,prevdata);
		display(first);
		break;
		case 3:
		printf("\nEnter the value to be inserted");
		scanf("%d",&data);
		printf("\nEnter the value to be inserted before:");
		scanf("%d",&prevdata);
		inbefore(&first,data,prevdata);
		display(first);
		break;
		case 4:
		printf("\nEnter the value to be inserted in beginning");
		scanf("%d",&data);
		inbeg(&first,data);
		display(first);
		break;
		case 5:
		printf("\nEnter the value to be deleted:");
		scanf("%d",&data);
		deleted(first,data);
		display(first);
		break;
		case 6:
		count(first);
		break;
		case 7:
		reverse(first);
	 }
	}
	while(choice!=0);
}
 void main()
 {
 int i,way;
 char funcion[50],argt[50],cart[50],dif[50];
 char SEN[4]="SEN";
 char COS[4]="COS";
 char TAN[4]="TAN";
 char CSC[4]="CSC";
 char SEC[4]="SEC";
 char COTAN[6]="COTAN";
 char LN[3]="LN";

 int a,b,c,r,x1,g,t;
 float resul,d1,f,f1,k,k1,d,l,m1,res,m2;
 char z[10],x[10],a1[10],a2[10],a3[10],a4[10],a5[10],a6[10];//res[10];
 int q,q2,q3,q4;
clrscr();
textcolor(01);
textbackground(003);
delay(3);
gotoxy(0,0);
printf("É");
for (q=1;q<=78;q++){
delay(3);
gotoxy(q,0);
printf("Í");
}
delay(3);
gotoxy(79,0);
printf("»");

for (q2=2;q2<=23;q2++){
delay(3);
gotoxy(80,q2);
printf("º");
}
delay(3);
gotoxy(80,24);
printf("¼");

for(q3=79;q3>=1;q3--){
delay(3);
gotoxy(q3,24);
printf("Í");
}
delay(3);
gotoxy(1,24);
printf("È");

for (q4=23;q4>=2;q4--){
delay(3);
gotoxy(1,q4);
printf("º");}

//marco1 ();
gotoxy(24,2);
printf("UNIVERSIDAD COOPERATIVA DE COLOMBIA\n");
gotoxy(30,4);
printf("TRABAJO DE MATEMATICAS \n");
gotoxy(32,7);
printf("INTEGRANTES :");
gotoxy(18,10);
printf("  KARINA ACOSTA          COD:5971004 ");
gotoxy(18,12);
printf("  LUIS BORREGO           COD:5971012 ");
gotoxy(18,14);
printf("  ISMEL CERCHAR          COD:5971018 ");
gotoxy(18,16);
printf("  INGRID ESCOBAR         COD:5971026 ");
gotoxy(18,18);
printf("  MAYERLY LOZANO         COD:5971034 ");
gotoxy(18,21);
printf("  PRESENTADO A: ");
gotoxy(32,21);
printf("   LIC: ALVARO MARRIAGA ");
gotoxy(30,23);
printf("DIGITE <ENTER> PARA CONTINUAR");
getch();
clrscr();
gotoxy(24,2);
printf("UNIVERSIDAD COOPERATIVA DE COLOMBIA\n");
gotoxy(30,4);
printf("TRABAJO DE MATEMATICAS \n");
gotoxy(32,7);
printf("INTEGRANTES :");
gotoxy(18,10);
printf("  ...................ASTRID CARRASQUILLA          ");
gotoxy(18,12);
printf("  ...................SANDRA GOMEZ            ");
gotoxy(18,14);
printf("  ...................BELKIS CUCUNUBA          ");
gotoxy(18,16);
printf("  ...................ALEJADRA MONERI         ");
gotoxy(18,18);
printf("  ...................SILAK DEL TORO         ");
gotoxy(18,20);
printf("  ...................MILENA TORRES         ");
gotoxy(18,22);
printf("  ...................ANA MARIA VAN-LEENDEN ");
gotoxy(18,24);
printf("  PRESENTADO A: ");
gotoxy(32,24);
printf("   LIC: ALVARO MARRIAGA ");


  getch();
  clrscr();
 /* printf("VALORES QUE SE UTILIZARAN MAS ADELANTE\n");
  scanf("%s%s%s%s%s%s",&a1,&a2,&a3,&a4,&a5,&a6);*/
    clrscr();

  gotoxy(30,12);
  printf(" SEGUNDO ORDEN ");
  getch();
  clrscr();
  gotoxy(5,2);
  printf(" FORMATO DE  ECUACIONES LINEALES CON COEFICIENTES VARIABLES\n");
  gotoxy(20,10);
  printf(" d^2y          dy   ");
  delay(50);
  gotoxy(20,11);
  printf(" ----   + R(x) --  +S(x)y  = Q(x)   \n");
  delay(200);
  gotoxy(20,12);
  printf(" dx^2          dx ");
  gotoxy(30,23);
  printf("DIGITE <ENTER> PARA CONTINUAR");

  getch();
  clrscr();
  printf("  d^2y  +  dy +  y =      ");
  gotoxy(9,1);
  scanf("%d",&b);
  gotoxy(15,1);
  scanf("%d",&c);
  gotoxy(22,1);
  scanf("%s",&x);
/////////////////////////////////////////////////////////////////////////////
//CASO I
  if((b==0)&&(c!=0)){
  //clrscr();
   k1=-c;
   if(k1<0){
   k1=(-1*k1);
   }
   k=sqrt(k1);
   f=-k;
   f1=k;

  printf("  las raices son :\n");
  printf("  %.2f i\n",f);
  printf("  %.2f i\n",f1);

  printf("  Yc = C1 cos     x + C2 sen       x ");
  gotoxy(14,5);
  printf("%.2f\n",f);
  gotoxy(30,5);
  printf("%.2f\n",f1);
  printf("  Yp=u1(x) Y1 + u2(x) Y2 \n");
  printf("  Y1=cos      x ");
  gotoxy(10,7);
  printf("%.2f\n",f);
  printf("  Y2=sen      x ");
  gotoxy(10,8);
  printf("%.2f\n",f1);


  //wronsquiano
  printf("W=");
  for (q2=12;q2<=14;q2++){
  delay(3);
  gotoxy(12,q2);
  printf("º");
  }
  for (q2=12;q2<=14;q2++){
  delay(3);
  gotoxy(21,q2);
  printf("º");
  }
  gotoxy(14,12);
  printf("Y1");
  gotoxy(18,12);
  printf("Y2");
  gotoxy(14,14);
  printf("Y`1");
  gotoxy(18,14);
  printf("Y`2");

  //////////////////////////////////
  gotoxy(22,13);
  printf("W=");

  for (q2=12;q2<=14;q2++){
  delay(3);
  gotoxy(24,q2);
  printf("º");
  }
  for (q2=12;q2<=14;q2++){
  delay(3);
  gotoxy(60,q2);
  printf("º");
  }
  gotoxy(26,12);
  printf("cos x^  ");
  gotoxy(33,12);
  printf("%.2f",f);
  gotoxy(47,12);
  printf("sen x^  ");
  gotoxy(53,12);
  printf("%.2f",f1);
  gotoxy(30,14);
  printf(" sen x^ ");
  gotoxy(25,14);
  printf("%.2f",f1*(-1));
  gotoxy(37,14);
  printf("%.2f",f1-1);
  gotoxy(47,14);
  printf("cos x^ ");
  gotoxy(43,14);
  printf("%.2f",f);
  gotoxy(53,14);
  printf("%.2f",f+1);
  gotoxy(22,16);
  printf("W =     cos^2 x^    +(     sen^2x^     )");
  res=f*f1;
  gotoxy(25,16);
  printf("%.2f",res);
  gotoxy(36,16);
  printf("%.2f",f1-1);

  gotoxy(44,16);
  printf("%.2f",res);
  gotoxy(58,16);
  printf("%.2f",f+1);
  gotoxy(22,17);
  printf("W = 1 ");
  gotoxy(31,18);
  printf("-sen x^     ");
  gotoxy(38,18);
  printf("%.2f ",f);
  gotoxy(46,18);
  printf("* %s ",x);
  // CALCULO DE U`1(X)
  gotoxy(23,19);
  printf("u`1(x) = ");
  gotoxy(31,19);
  printf("---------------------------------------------");
   gotoxy(43,20);
   printf(" 1");
/*  printf("  =     cos^2 x^    +(      sen^2x^      )");
  res=f*f1;
  gotoxy(33,20);
  printf("%.2f",res);
  gotoxy(44,20);
  printf("%.2f",f1-1);

  gotoxy(53,20);
  printf("%.2f",res);
  gotoxy(66,20);
  printf("%.2f",f+1); */
  if(x==0){
  gotoxy(22,22);
 printf("u`1(x) =   %s",x);
 }
  //CALCULO DE U`2(X)
/*  gotoxy(46,25);
  printf("u`2(x) = ");
  gotoxy(33,25);
  printf("----------");
  gotoxy(55,26);
  printf(" * e^  x");
  gotoxy(34,26);
  printf("%.0f",k1);
  gotoxy(39,26);
  printf("%.0f",k1);
  // z=(-1*x);
  gotoxy(45,25);
  printf("u`2(x) =   %s",x);
  */
  getch();
  }
  ////////////////////////////////////////////////////////////////////////////
  // CASO II
  if((c==0)&&(b!=0)){
  d=0;
  d1=-b;
  printf("%.2f\n",d);
  printf("%.2f\n",d1);
  printf("Yc = C1 + C2e^  x");
  gotoxy(15,4);
  printf("%.0f\n",d1);
  printf("Y1=1\n");
  printf("dY1=0\n");
  printf("Y2=e^  x\n");
  gotoxy(6,7);
  printf("%.0f\n",d1);
  printf("dY2=  * e^  x ");
  gotoxy(5,8);
  printf("%.0f",d1);
  gotoxy(11,8);
  printf("%.0f",d1);
  getch();
  //wronquiano
  clrscr();
  gotoxy(30,1);
  printf("METODO WROQUIANO");

  gotoxy(10,5);
  printf("W=");
  for (q2=4;q2<=6;q2++){
  delay(3);
  gotoxy(12,q2);
  printf("º");
  }
  for (q2=4;q2<=6;q2++){
  delay(3);
  gotoxy(21,q2);
  printf("º");
  }
  gotoxy(14,4);
  printf("Y1");
  gotoxy(18,4);
  printf("Y2");
  gotoxy(14,6);
  printf("Y`1");
  gotoxy(18,6);
  printf("Y`2");

  //////////////////////////////////
  gotoxy(22,5);
  printf("W=");

  for (q2=4;q2<=6;q2++){
  delay(3);
  gotoxy(24,q2);
  printf("º");
  }
  for (q2=4;q2<=6;q2++){
  delay(3);
  gotoxy(42,q2);
  printf("º");
  }
  gotoxy(26,4);
  printf("1");
  gotoxy(34,4);
  printf("e^  x");
  gotoxy(36,4);
  printf("%.0f",d1);
  gotoxy(26,6);
  printf("0");
  gotoxy(31,6);
  printf("  * e^  x");
  gotoxy(32,6);
  printf("%.0f",d1);
  gotoxy(37,6);
  printf("%.0f",d1);
  gotoxy(22,8);
  printf("W =  * e^  x");
  gotoxy(25,8);
  printf("%.0f",d1);
  gotoxy(31,8);
  printf("%.0f",d1);
  //CALCULO DE U`1(X)
  gotoxy(31,10);
  printf("-e^  x*  ");
  gotoxy(34,10);
  printf("%.0f ",d1);
  gotoxy(39,10);
  printf("%s ",x);
  gotoxy(23,11);
  printf("u`1(x) = ");
  gotoxy(31,11);
  printf("----------");
  gotoxy(33,12);
  printf(" * e^  x");
  gotoxy(34,12);
  printf("%.0f",d1);
  gotoxy(39,12);
  printf("%.0f",d1);
// z=(-1*x);
  gotoxy(45,11);
  printf("u`1(x) =   %s/ %.0f",x,d1*-1);
   gets(x);
 for (i=0; i<strlen(x); i++)
 {
 argt[i]=toupper(x[i]);
 }
  //argt[i]=x;
  if (!strcmp(argt,SEN))
  {
   strcpy(dif,"-");
   strcat(dif,COS);
   }
  if (!strcmp(argt,COS))
    strcpy(dif,SEN);
  if (!strcmp(argt,TAN))
   {
   strcpy(dif,LN);
   strcat(dif," ");
   strcat(dif,"(");
   strcat(dif,SEC);
   strcat(dif,")");
   }
  if (!strcmp(argt,SEC))
  {
   strcpy(dif,LN);
   strcat(dif," ");
   strcat(dif,"(");
   strcat(dif,SEC);
   strcat(dif,"+");
   strcat(dif,TAN);
   strcat(dif,")");
   }
  if (!strcmp(argt,CSC))
  {
   strcpy(dif,"-");
   strcat(dif,LN);
   strcat(dif," ");
   strcat(dif,"(");
   strcat(dif,CSC);
   strcat(dif,"+");
   strcat(dif,COTAN);
   strcat(dif,")");
  }
  if (!strcmp(argt,COTAN))
  {
   strcpy(dif,"-");
   strcat(dif,LN);
   strcat(dif,"(");
   strcat(dif,CSC);
   strcat(dif,")");
  }

  printf("LA INTEGRAL DE LA FUNCION ES: %s",dif);


  //CALCULO U`2(X)
  gotoxy(31,14);
  printf(" 1 * ");
  gotoxy(34,14);
 // printf("%.0f ",d1);
  gotoxy(35,14);
  printf("%s ",x);
  gotoxy(23,15);
  printf("u`2(x) = ");
  gotoxy(31,15);
  printf("----------");
  gotoxy(33,16);
  printf(" * e^  x");
  gotoxy(34,16);
  printf("%.0f",d1);
  gotoxy(39,16);
  printf("%.0f",d1);
// z=(-1*x);
  gotoxy(45,15);
  printf("u`2(x) =   %s /   * e^   x",x);
  gotoxy(60,15);
  printf("%.0f",d1);
  gotoxy(67,15);
  printf("%.0f",d1);
 //////////////////
 //integrando u`1 y  u`
   getch();
  }
  ///////////////////////////////////////////////////////////////////////////
  // TERCER CASO
  if((b!=0)&&(c!=0)){
  a=1;
  g=(a*2);
  printf("%d\n",g);
  x1=(-4*c);
  printf("%d\n",x1);
  r=(b*b);
  printf("%d\n",r);
  t=r-x1;
  printf("%d\n",t);
  resul=sqrt(t);
  printf("%f",resul);
 m1=(-b+resul)/g;
 m2=(-b-resul)/g;
 gotoxy(30,15);
 printf("%.2f %.2f",m1,m2);
getch();

 }








//  getch();


   }
void main()
{
 clrscr();
 contacts();
 getch();
}
Beispiel #22
0
void train :: modify(unsigned int t_no) {

      clrscr();
      int flag = 0;
      fstream file;
      file.open("TRAIN.DAT",ios::in | ios::out | ios::ate | ios::binary);
      file.seekg(0,ios::beg);

      file.read((char*)this, sizeof(train));
      for(int j = 0; !file.eof(); ++j)
       {
	  if (t_no == train_no)
	  { flag = 1;
	    cout << endl << "DISPLAYING CURRENT TRAIN INFORMATION !!"<<endl;
	    cout << endl << "Train No. : ";
	    cout << train_no;
	    cout << endl << "Name of Train : ";
	    puts(train_name);
	    getch();
	    clrscr();

	    cout << " Information of five stations en route the train :"
		 << endl;
	    getch();

	    for (int i = 0; i < 5; ++i)
	    {
	      clrscr();
	      cout << endl << "Info for Station : " << i+1;
	      cout << endl << endl << "Name of Station : ";
	      puts(s[i].name);
	      cout << "Arrival time   (hh:mm) : ";
	      puts(s[i].arr_time);
	      gotoxy(31,5);
	      clreol();
	      gotoxy(1,6);
	      cout << "Departure time (hh:mm) : ";
	      puts(s[i].dep_time);
	      gotoxy(31,6);
	      clreol();
	      getch();
	    }

	    clrscr();
	    cout << endl << "Capacity of the train : ";
	    cout << capacity;

	    cout << endl << endl;
	    cout << "ENTER NEW INFORMATION !!" << endl;
	    cout << endl << "Train No. : ";
	    cin  >> train_no;
	    cout << endl << "Name of Train : ";
	    gets(train_name);
	    clrscr();

	    cout << "Enter Information of five stations en route the train :"
		 << endl;
	    getch();

	    for ( i = 0; i < 5; ++i)
	    {
	      clrscr();
	      cout << endl << "Enter Info for Station : " << i+1;
	      cout << endl << "Name of Station : ";
	      gets(s[i].name);
	      cout << "Enter Arrival time   (hh:mm) : ";
	      gets(s[i].arr_time);
	      cout << "Enter Departure time (hh:mm) : ";
	      gets(s[i].dep_time);
	    }

	    getch();
	    clrscr();
	    cout << endl << "Enter capacity of the train : ";
	    cin  >> capacity;

	    file.seekp(j*(sizeof(train)),ios::beg);
	    file.write((char*)this, sizeof(train));
	  }
       file.read((char*)this, sizeof(train));
       }
Beispiel #23
0
main()
      { char ch;
	FILE *fp;
	clrscr();
	fp=fopen("zip1.txt","r");
	if(fp==NULL) printf("\nThere is no file");
	else
	while(!feof(fp))
	{
	  ch=fgetc(fp);
	 switch(ch)
		  {
		   case 'a': a+=1; node[1].num=a;node[1].chr='a';break;
		   case 'b': b+=1; node[2].num=b;node[2].chr='b';break;
		   case 'c': c+=1; node[3].num=c;node[3].chr='c';break;
		   case 'd': d+=1; node[4].num=d;node[4].chr='d';break;
		   case 'e': e+=1; node[5].num=e;node[5].chr='e';break;
		   case 'f': f+=1; node[6].num=f;node[6].chr='f';break;
		   case 'g': g+=1; node[7].num=g;node[7].chr='g';break;
		   case 'h': h+=1; node[8].num=h;node[8].chr='h';break;
		   case 'i': i+=1; node[9].num=i;node[9].chr='i';break;
		   case 'j': j+=1; node[10].num=j;node[10].chr='j';break;
		   case 'k': k+=1; node[11].num=k;node[11].chr='k';break;
		   case 'l': l+=1; node[12].num=l;node[12].chr='l';break;
		   case 'm': m+=1; node[13].num=m;node[13].chr='m';break;
		   case 'n': n+=1; node[14].num=n;node[14].chr='n';break;
		   case 'o': o+=1; node[15].num=o;node[15].chr='o';break;
		   case 'p': p+=1; node[16].num=p;node[16].chr='p';break;
		   case 'q': q+=1; node[17].num=q;node[17].chr='q';break;
		   case 'r': r+=1; node[18].num=r;node[18].chr='r';break;
		   case 's': s+=1; node[19].num=s;node[19].chr='s';break;
		   case 't': t+=1; node[20].num=t;node[20].chr='t';break;
		   case 'u': u+=1; node[21].num=u;node[21].chr='u';break;
		   case 'v': v+=1; node[22].num=v;node[22].chr='v';break;
		   case 'w': w+=1; node[23].num=w;node[23].chr='w';break;
		   case 'x': x+=1; node[24].num=x;node[24].chr='x';break;
		   case 'y': y+=1; node[25].num=y;node[25].chr='y';break;
		   case 'z': z+=1; node[26].num=z;node[26].chr='z';break;
		  }

	}
	sort();
	if(a!=0)printf("a=%d\t",a);
	if(b!=0)printf("b=%d\t",b);
	if(c!=0)printf("c=%d\t",c);
	if(d!=0)printf("d=%d\t",d);
	if(e!=0)printf("e=%d\t",e);
	if(f!=0)printf("f=%d\t",f);
	if(g!=0)printf("g=%d\t",g);
	if(h!=0)printf("h=%d\t",h);
	if(i!=0)printf("i=%d\t",i);
	if(j!=0)printf("j=%d\t",j);
	if(k!=0)printf("k=%d\t",k);
	if(l!=0)printf("l=%d\t",l);
	if(m!=0)printf("m=%d\t",m);
	if(n!=0)printf("n=%d\t",n);
	if(o!=0)printf("o=%d\t",o);
	if(p!=0)printf("p=%d\t",p);
	if(q!=0)printf("q=%d\t",q);
	if(r!=0)printf("r=%d\t",r);
	if(s!=0)printf("s=%d\t",s);
	if(t!=0)printf("t=%d\t",t);
	if(u!=0)printf("u=%d\t",u);
	if(v!=0)printf("v=%d\t",v);
	if(w!=0)printf("w=%d\t",w);
	if(x!=0)printf("x=%d\t",x);
	if(y!=0)printf("y=%d\t",y);
	if(z!=0)printf("z=%d\t",z);
	total=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z;
	printf("\n%d",total);
	int tt=total+1;
	while(tt!=1)
	{
	 tt=tt/2;
	 height+=1;
	}
	printf(" %d",height);
	lad=(pow(2,height))-1;
	printf("\n%d",lad);
	tt=1;
	while(node[tt].num==0)
	{
	 tt++;
	}
	hepcre(lad,tt);
	getch();
}
Beispiel #24
0
main()
{
	una:
	clrscr();

	g(31,4);
	p("[A] Exercise 1");
	g(31,5);
	p("[B] Exercise 2");
	g(31,6);
	p("[C] Exercise 3");
	g(31,7);
	p("[D] Exercise 4");
	g(31,8);
	p("[E] Exercise 5");
	g(31,9);
	p("[F] Exercise 6");
	g(31,10);
	p("[G] Exercise 7");
	g(31,11);
	p("[H] Exercise 8");
	g(31,12);
	p("[I] Exercise 9");
	g(31,13);
	p("[J] Exercise 10");
	g(31,14);
	p("[K] Exercise 11");
	g(31,15);
	p("[X] Exit");
	g(20,18);
	p("Please input the letter of your choice: ");
	s("%s",&menu);

	switch(menu)
	{
		case 'a':
		case 'A':
			clrscr();

			for(i=0;i<5;i++)
			{
				p("August\n");
			}

			p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'b':
		case 'B':
			clrscr();

			p("Please input a number: ");
			s("%i",&n);

			for(i=0;i<n;i++)
			{
				p("number %i\n",i);
			}

                        p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'c':
		case 'C':
			clrscr();

			p("Skip count by: ");
			s("%i",&skip);
			p("Maximum: ");
			s("%i",&max);

			for(i=0;i<=max;i=i+skip)
			{
				p("%i\n",i);
			}

                        p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'd':
		case 'D':
			clrscr();

			for(a=0;a<3;a++)
			{
				for(b=0;b<4;b++)
				{
					p("sam\n");
				}
			}

                        p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'e':
		case 'E':
			clrscr();

			for(a=0;a<3;a++)
			{
				for(b=0;b<4;b++)
				{
					p("%i%i\n",a,b);
				}
			}

                        p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'f':
		case 'F':
			clrscr();

			g(31,4);
			p("C O U N T D O W N\n");
			g(32,5);
			p("input number: ");
			s("%i",&n);

			for(min=n-1;min>=0;min--)
			{
				for(sec=59;sec>=0;sec--)
				{
					for(mil=1000;mil>=0;mil--)
					{
						clrscr();
						p("%i:%i:%i",min,sec,mil);
					}
				}
			}

                        p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'g':
		case 'G':
			clrscr();

			a=3;
			b=4;
			c=1;

			t=(b>a);
			u=(a==c);
			v=(a!=c);
			w=(c<=a);
			x=((b>a)||(b<3));
			y=((b>a)&&(b<3));
			z=((b>a)&&!(b<3));

			p("t is %i\n",t);
			p("u is %i\n",u);
			p("v is %i\n",v);
			p("w is %i\n",w);
			p("x is %i\n",x);
			p("y is %i\n",y);
			p("z is %i\n",z);

                        p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'h':
		case 'H':
			clrscr();

			p("The new ADCS grading system\nPlease enter a grade: ");
			s("%i",&x);

			if(x>=95)
			{
				p("Grade is A");
			}
			else if(x>=85)
			{
				p("Grade is B");
			}
			else if(x>=75)
			{
				p("Grade is C");
			}
			else
			{
				p("FAILED!");
			}

                        p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'i':
		case 'I':
			clrscr();

			p("Please input a number: ");
			s("%i",&x);

			if((x%2==0)&&(x%3==0))
			{
				p("Divisible by 2 and 3");
			}
			else if(x%2==0)
			{
				p("Divisible by 2");
			}
			else if(x%3==0)
			{
				p("Divisible by 3");
			}
			else
			{
				p("Not Divisible by 2 and 3");
			}

                        p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'j':
		case 'J':
			clrscr();

			p("Please enter a number: ");
			s("%i",&x);

			switch(x)
			{
				case 0:	p("zero");
				break;

				case 1:	p("one");
				break;

				case 2:	p("two");
				break;

				case 3:	p("three");
				break;

				default: p("invalid input");
			}

                        p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'k':
		case 'K':
			clrscr();

			p("Please enter 2 number: ");
			s("%i%i",&x,&y);

			switch(x+y)
			{
                        	case 0:	p("zero");
				break;

				case 1:	p("one");
				break;

				case 2:	p("two");
				break;

				case 3:	p("three");
				break;

				case 4: p("four");
				break;

				case 5: p("five");
				break;

				default: p("above FIVE");
			}

                        p("\nView another exercise [Y/N]? ");
			s("%s",&m);
			if(m == 'y' || m == 'Y')
			{
				goto una;

			}
			else
			{
				exit();
			}
		break;

		case 'x':
		case 'X':
			exit();
		break;

		default:
			g(32,20);
			p("Invalid input");



	}

getch();
}
Beispiel #25
0
int main (int argc, char **argv)
{
    char *fname = (char*)"base2.dat";   /* имя файла БД */
    orgDBase *ptr_dbHead;               /* указатель на начало массива записей из БД */
    DBQueue* sr_keyQueue;
    stAVLTree *tr_srchRoot;

    /* загрузка БД из файла в память */
    CharToOem("Загрузка БД...", oem_str);
    printf("%s\n", oem_str);
    dbase_loadFromFile(fname);

    ind_buildIndexArray();

    /* Вывод на экран полей БД из памяти */
    clrscr();

    int index = 0;
    char c;
    while(true) {
      dbase_drawTable(index);
      c = getch();
      switch(c) {
        case 113 :
          clrscr();
          printf("Search: ");
          char key[2];
          scanf("%s", &key);
          sr_keyQueue = NULL;
          sr_keyQueue = dbase_searchByKey(key);
          /* Debug
           * queuePrint(sr_keyQueue);
           * */
          CharToOem("Найдено элементов: ", oem_str);
          printf("%s%d\n", oem_str, sr_keyQueue->queueGetSize());
          tr_srchRoot = NULL;
          tr_srchRoot = tr_buildAVLTree(sr_keyQueue, sr_keyQueue->queueGetSize());
          /* Debug
           * CharToOem("АВЛ-дерево:", oem_str);
           * printf("\n%s\n", oem_str);
           * tr_goFromLeftToRight(tr_srchRoot, 0);
           * */

          CharToOem("Средняя высота дерева: ", oem_str);
          printf("%s%5.2f\n", oem_str, tr_getAverageHeight(tr_srchRoot));
          CharToOem("Поиск в дереве: ", oem_str);
          printf("%s", oem_str);
          scanf("%d", &c);
          if ((c > 0) && (c < 32)) {
                int t_count = 0;
                stAVLTree* findElem; // найденный элемент
                CharToOem("Ключ ", oem_str);
                printf("%s", oem_str);
                bool isFind = true;
                if (!tr_searchInTree(tr_srchRoot, c, &t_count, &findElem)) {
                        CharToOem("не ", oem_str);
                        printf("%s", oem_str);
                        isFind = false;
                }
                CharToOem("найден в дереве.", oem_str);
                printf("%s\n", oem_str);
                CharToOem("Переходов: ", oem_str);
                printf("%s%d\n", oem_str, t_count);

                if (isFind) {
                printf("%c", 201);
                for (int i = 0; i < 80 - 2; i++)
                      printf("%c", 205);
                printf("%c", 187);
                printf("%c", 186);
                printf("           Employer name           %c  #"
                       "  %c          Post          %c Birth day"
                       " ", 179, 179, 179);
                printf("%c", 186);

                printf("%c", 204);
                for (int i = 0; i < 80 - 2; i++)
                        printf("%c", 205);
                printf("%c", 185);

                printf("%c", 186);
                printf("  ");
                for (int i = 0; i < NAMESIZE; i++)
                        printf("%c", findElem->key->name[i]);
                printf(" %c ", 179);

                printf("%3d", findElem->key->depnum);
                printf(" %c ", 179);

                for (int i = 0; i < POSTSIZE; i++)
                        printf("%c", findElem->key->post[i]);
                printf(" %c ", 179);

                for (int i = 0; i < BDATESIZE; i++)
                        printf("%c", findElem->key->bdate[i]);
                printf("  ");
                printf("%c", 186);

                for (int i = 0; i < findElem->eqCount; i++) {

                        printf("%c", 186);
                        printf("  ");
                        for (int j = 0; j < NAMESIZE; j++)
                                printf("%c", findElem->eq[i]->name[j]);
                        printf(" %c ", 179);

                        printf("%3d", findElem->eq[i]->depnum);
                        printf(" %c ", 179);

                        for (int j = 0; j < POSTSIZE; j++)
                                printf("%c", findElem->eq[i]->post[j]);
                        printf(" %c ", 179);

                        for (int j = 0; j < BDATESIZE; j++)
                                printf("%c", findElem->eq[i]->bdate[j]);
                        printf("  ");
                        printf("%c", 186);
                }

                printf("%c", 200);
                for (int i = 0; i < 80 - 2; i++)
                      printf("%c", 205);
                printf("%c\n", 188);
                }
          } else {
                CharToOem("Значение ключа поиска вне диапазона!", oem_str);
                printf("%s\n", oem_str);
          }
          getch();
          clrscr();
          break;

        case 115 :
          ind_sortHoarArray(0, empCount-1);
          break;

        case 72 :
          if (index > 0) index--;
          break;

        case 80 :
          if (index < empCount - 15) index++;
          break;

        case 73 :
          if (index > 0) {
            if ((index - 15) >= 0) index -=15;
          }
          break;

        case 81 :
          if (index < empCount - 15) {
            if ((index + 15) < empCount - 15) index +=15;
            else index = empCount - 15;
          }
          break;

        case 27 :
          free(indDBArrayElem);
          free(orgDBArray);
          return 0;
      }
    }
}
Beispiel #26
0
void main()
{
    int s[SIZE]= {0};
    int top= -1;
    int ch, pos, item;
    clrscr();
    do
    {
        clrscr();
        printf("\n 1 for Push");
        printf("\n 2 for Pop");
        printf("\n 3 for Peep");
        printf("\n 4 for Change");
        printf("\n 5 for Display");
        printf("\n 6. for Exit");

        printf("\n\t Enter choice:");
        scanf("%d", &ch);

        switch(ch)
        {
        case 1 :
            printf("\n\t Enter item for push:");
            scanf("%d", &item);
            push(s,top,item);
            getch();
            break;

        case 2 :
            item = pop(s,top);
            if(item!=-1)
                printf("\n\t%d is popped",item);
            getch();
            break;

        case 3:
            printf("\n\tEnter pos for peep:");
            scanf("%d",&pos);

            item = peep(s,top,pos);

            if(item!=-1)
                printf("%d",item);

            getch();
            break;

        case 4:
            printf("\n\tEnter new item :");
            scanf("%d",&item);
            printf("\n\tEnter pos:");
            scanf("%d",&pos);
            change(s,top,pos,item);
            getch();
            break;

        case 5 :
            display(s,top);
            getch();
            break;

        case 6 :
            printf("\n\t Thanks...!");
            getch();
            exit(0);
            break;

        default :
            printf("\n\t Wrong choice...!");
            getch();
            break;
        }
    } while(ch!=6);
    getch();
}
Beispiel #27
0
void main()
{
node *origin;
node *disply;
node *insert;
node *remove;
node *previous;
node *ever;
node *add;
char choice;
int option,chk,flag=0,first;
origin=(node *)malloc(sizeof(node));
disply=origin;
insert=origin;
remove=origin;
     while(2)
     {
     clrscr();
     window(1,1,79,24);
     textcolor(BLUE);
     textbackground(LIGHTGRAY);
     cprintf("");
     printf("\n\t############ LINK LIST OPERATIONS MENU ############## ");
     printf("\n\n\t\t 1: CREATE ");
     printf("\n\t\t 2: DISPLAY ");
     printf("\n\t\t 3: INSERT ");
     printf("\n\t\t 4: REMOVE ");
     printf("\n\t\t 5: EXIT ");
     cprintf("");
     option=getch();
     switch(option)
     {
     case '1':
     {
     origin=ever;
     while(1)
     {
     clrscr();
     printf("\n\t\t########## CREATING LINK LIST ##########");
     printf("\n\tenter the name: ");
     fflush(stdin);
     gets(origin->name);
     printf("\n\tenter the phone number: ");
     fflush(stdin);
     scanf("%ld",&origin->phone);
     printf("\n\tNAME : %s ",origin->name);
     printf("\n\tPHONE : %ld ",origin->phone);
     printf("\n\n\t\tmore...y/n ");
     fflush(stdin);
     choice=getchar();
     if(toupper(choice)=='N')
     {
     origin->next=0;
     break;
     }
     origin->next=(node *)malloc(sizeof(node));
     origin=origin->next;
     }
     break;
     }
     case '2':
     {
     disply=ever;
     while(1)
     {
     clrscr();
     window(5,5,75,15);
     textbackground(BLACK);

     printf("\n\n\t ########## DISPLAYING LINKLIST ##########");
     printf("\n\tNAME : %s ",disply->name);
     printf("\n\tPHONE : %ld ",disply->phone);
     getch();
     if(disply->next==NULL)
     break;
     disply=disply->next;
     fflush(stdin);
     }
     break;
     }
     case '3':
     {
     insert=ever;
     while(3)
     {
     clrscr();
     fflush(stdin);
     printf(" \n\t\t ########## NODE INSERTION WINDOW ########## ");
     printf("\n\n the name of the person after which you wish to insert : ");
     gets(target);
     while(4)
     {
     chk=strcmpi(insert->name,target);
     if(chk==0)
     {
     printf("\n\tmatch found.. ");
     add=(node *)malloc(sizeof(node));
     printf("\n\tenter the name : ");
     fflush(stdin);
     gets(add->name);
     printf("\n\tenter the phone number : ");
     scanf("%ld",&add->phone);
     printf("\n\tNAME : %s ",add->name);
     printf("\n\tPHONE : %ld ",add->phone);
     add->next=insert->next;
     insert->next=add;
     getch();
     flag=1;
     }
     if(flag==1)
     break;
     //previous=insert;
     insert=insert->next;
     chk=strcmpi(insert->name,target);
     if(chk==0)
     continue;
     if(insert->next==NULL )
     {
     printf("\n\n\tmatch not found....");
     getch();
     break;
     }
     }
     printf(" \n\t want to insert another ");
     fflush(stdin);
     insert=ever;
     flag=0;
     choice=getchar();
     if(toupper(choice)=='N')
     break;
     }
     break;
     }
     case '4':
     {
     remove=ever;
     previous=ever;
     first=0;
     while(3)
     {
     clrscr();
     fflush(stdin);
     printf(" \n\t\t ########## NODE  DELETION  WINDOW ########## ");
     printf(" Enter the name of the person whom you wish to delete : ");
     gets(target);
     while(4)
     {
     chk=strcmpi(remove->name,target);
     if(chk==0)
     {
     printf("\n\tmatch found.. ");
     if(first==0)
     {
     ever=remove->next;
     getch();
     flag=1;
     break;
     }
     if(flag==1)
     break;
     previous->next=remove->next;
     getch();
     flag=1;
     }
     if(flag==1)
     break;
     previous=remove;
     remove=remove->next;
     first=1;
     chk=strcmpi(remove->name,target);
     if(chk==0)
     continue;
     if(remove->next==NULL )
     {
     printf("\n\n\tmatch not found....");
     getch();
     break;
     }
     }
     printf(" \n\t want to remove another ");
     fflush(stdin);
     remove=ever;
     flag=0;
     choice=getchar();
     if(toupper(choice)=='N')
     break;
  }
  break;
}
     case '5':
     exit(0);
}
}
}
Beispiel #28
0
void quantity()
{
	int ch,no,rq,f=0,search;
	fp1=fopen("item.dat","rb");
	fp2=fopen("qty.dat","ab+");
	clrscr();

	do
	{
		clrscr();

                printf("\n\n\t\t ************************* \n");
        	printf("\t\t   Reordering Quantity \n");
      	        printf("\t\t ************************* \n");

		printf("\n\n\t\t\t 1... Insert ");
		printf("\n\t\t\t 2... Update ");
		printf("\n\t\t\t 3... Display ");
		printf("\n\n\t\t\t 99.. Exit ");
		printf("\n Enter Your Choice :");
		scanf("%d",&ch);

		switch(ch)
		{
			case 1:
				fp1=fopen("item.dat","rb");
				f=0;

				printf("\n Enter Item Number : ");
				scanf("%d",&no);
				printf(" Enter Reorder Quantity: ");
				scanf("%d",&rq);

				while(fread(&i,sizeof(i),1,fp1)==1)
				{
					if(no==i.item_no)
					{
						q.item_no=no;
						q.qty=rq;

						fwrite(&q,sizeof(q),1,fp2);

						printf("\n Added...");
							f=1;
							break;
					}
				}

				if(f==0)
					printf("\n Invalid Item Number");

				fclose(fp1);
				break;
			case 3:
				rewind(fp2);
				f=0;

                                printf("\n ITEM NO \t QUANTITY \n");

				while(fread(&q,sizeof(q),1,fp2)==1)
				{
					printf("\n %d \t\t %d",q.item_no,q.qty);
					f=1;
				}

				if(f==0)
				{
					printf("\n No Record Found...");
				}
				break;
			case 2:
				fp3=fopen("temp.dat","wb");
				rewind(fp2);
				f=0;

				printf("\n Enter Item Number : ");
				scanf("%d",&search);

				while(fread(&q,sizeof(q),1,fp2)==1)
				{
					if(q.item_no==search)
					{
						printf(" Enter Reorder Quntity : ");
						scanf("%d",&q.qty);
						f=1;
					}
					fwrite(&q,sizeof(q),1,fp3);
				}

				if(f==0)
				{
					printf("\n Invalid Item Number");
				}
				else
				{
					fclose(fp2);
					fclose(fp3);

					remove("stock.dat");
					rename("temp.dat","stock.dat");

					fp2=fopen("stock.dat","ab+");

					printf("\n Updated....");
				}
				break;

			case 99:
				fclose(fp1);
				fclose(fp2);

				//exit(0);
				break;
		}
		getch();
	}while(ch!=99);
getch();
}
/* This function retreives data from the database as well as do data processing according to user requests.
   The function provides functionality for menu options provided to both employee as well as administrator user*/
void getData(int option)
{
 FILE *db,*tempdb;
 char anotherEmp;
 int choice;
 int showMenu,posx,posy;
 char checkSave,checkAddNew;
 int i;

 struct employee
 {
        char firstname[30];
  char lastname[30];
	char password[30];
	int  empid;
	char contact[30];
	char bgr[4];
	char date[10];
	char loginhour;
	char loginmin;
	char loginsec;
	char logouthour;
	char logoutmin;
	char logoutsec;
	int yr;
	char mon;
	char day;
 };

 struct employee empData;

 char confirmPassword[30];
 long int size;
 char lastNameTemp[30],firstNameTemp[30],password[30],contact[30],bgr[4], date[10];
 int searchId;
 char pass[30];
 char findEmployee;
 char confirmDelete;

 struct date today;
 struct time now;

 clrscr();

 /* Opens the Employee Database*/
 db=fopen("d:/empbase.dat","rb+");
 if(db==NULL)
	{
		db=fopen("d:/empbase.DAT","wb+");
		if(db==NULL)
		{
			printf("The File could not be opened.\n");
			exit();
		}
	}
  printf("Application Database \n");
  size=sizeof(empData);
  showMenu=0;
  while(showMenu==0)
  {
   fflush(stdin);
   choice=option;

   /* Based on the choice selected by admin/employee, this switch statement processes the request*/
   switch(choice)
   {

   /* To add a new employee to the database*/
   case 1:
	   fseek(db,0,SEEK_END);
	   anotherEmp='y';

	   while(anotherEmp=='y')
	   {
                   checkAddNew=0;
		   while(checkAddNew==0)
		   {
		   clrscr();
		   gotoxy(25,3);
		   printf("ADD A NEW STUDENT");
		   gotoxy(13,22);
		   printf("Warning: Password Must Contain Six(6) AlphaNumeric Digits.");
		   gotoxy(5,8);
		   printf("Enter First Name: ");
		   scanf("%s",&firstNameTemp);
		   gotoxy(5,10);
		   printf("Enter Last Name: ");
		   scanf("%s",&lastNameTemp);
            gotoxy(5,12);
		   printf("Enter Blood Group: ");
		   scanf("%s",&bgr);
		   gotoxy(5,14);
		   printf("Enter Contact No: ");
		   scanf("%s",&contact);


		   gotoxy(43,8);
		   printf("Enter Password: "******"* ");
		   }
		   password[6]='\0';

		   while(getch()!=13);

		   gotoxy(43,10);
		   printf("Confirm Password: "******"* ");
		   }
		   confirmPassword[6]='\0';

		   while(getch()!=13);
		   if (strcmp(password,confirmPassword))
		   {
		      gotoxy(24,12);
        	      printf("Passwords do not match.");
		      gotoxy(23,13);
		      printf("Press any key to continue.");
		      getch();
		   }
		   else
		   {
		   checkAddNew=1;
		   rewind(db);
		   empData.empid=0;
		   while(fread(&empData,size,1,db)==1);
		   if (empData.empid<2000)
		   empData.empid=20400;

		   empData.empid=empData.empid+1;
		   gotoxy(30,16);
		   printf("Save Student Information? (y/n): ");
		   checkSave=getche();
		   if (checkSave=='y')
		   {
		   strcpy(empData.firstname,firstNameTemp);
		   strcpy(empData.lastname,lastNameTemp);

		   strcpy(empData.bgr,bgr);
		   strcpy(empData.contact,contact);
		   strcpy(empData.date,date);
		   strcpy(empData.password,password);
		   empData.loginhour='t';
		   empData.logouthour='t';
		   empData.day='j';
		   fwrite(&empData,size,1,db);
		   }
		   gotoxy(28,16);
		   printf("                        ");
		   gotoxy(31,16);
		   printf("Would like to add another student? (y/n):");
		   fflush(stdin);
		   anotherEmp=getche();
		   printf("\n");
		   }
		   }
	   }
	   break;

   /* To view time records for all employees*/
   case 2:

	   clrscr();
	   gotoxy(21,2);
	   printf("  .     VIEW STUDENT INFORMATION ");
	    gotoxy(21,3);
	   printf("           ~CSTE - 7th Batch~ ");
	   gotoxy(1,5);
	   printf("  ID:        Student Name:      Student Blood Gr:  Contact No:     Date of log\n\n");
	   rewind(db);
	   posx=3;
	   posy=7;
	   while(fread(&empData,size,1,db)==1)
	   {
	    empData.firstname[0]=toupper(empData.firstname[0]);
	    empData.lastname[0]=toupper(empData.lastname[0]);
	    gotoxy(posx,posy);
	    printf("%d",empData.empid);
	    gotoxy(posx+10,posy);
	    printf("| %s, %s",empData.firstname,empData.lastname);
	    gotoxy(posx+30,posy);
	    	    printf("%s",empData.bgr);
gotoxy(posx+30,posy+2);
	    if (empData.loginhour=='t')
	    {
	     printf("");
	    }
	    else
	    printf("");

	    gotoxy(posx+49,posy);

	    printf("%s",empData.contact);

	    if (empData.logouthour=='t')
	    {
	    printf("");
	    }
	    else
	    printf("");
	    if (empData.day=='j')
	    {
	    gotoxy(posx+64,posy);
	    printf("| Not Log yet");
	    }
	    else
	    {
	    gotoxy(posx+64,posy);
	    printf("| %d/%d/%d",empData.mon,empData.day,empData.yr);
	    }

	    posy=posy+1;
	   }
       	   getch();

	   printf("\n");
	   break;

  /* To search a particular employee and view their time records*/
  case 3:

	   clrscr();
	   gotoxy(27,5);
	   printf("SEARCH STUDENT INFORMATION");
	   gotoxy(25,9);
	   printf("Enter Student Id to Search: ");
	   scanf("%d", &searchId);
	   findEmployee='f';
	   rewind(db);
           while(fread(&empData,size,1,db)==1)
	   {
	       if (empData.empid==searchId)
	       {
		gotoxy(33,11);
		textcolor(YELLOW+BLINK);
		cprintf("Student Information is Available.");
		textcolor(YELLOW);
		gotoxy(25,13);
		printf("Student name is: %s %s",empData.firstname,empData.lastname);
		if(empData.loginhour=='t')
		{
		gotoxy(25,14);
		printf("Log In Time: Not Logged In");
		}
		else
		{
		gotoxy(25,14);
		printf("Log In Time is: %d:%d:%d",empData.loginhour,empData.loginmin,empData.loginsec);
		}
		if(empData.logouthour=='t')
		{
		gotoxy(25,15);
		printf("Log Out Time: Not Logged Out");
		}
		else
		{
		gotoxy(25,15);
		printf("Log Out Time is: %d:%d:%d",empData.logouthour,empData.logoutmin,empData.logoutsec);
		}
		findEmployee='t';
	       getch();
	       }
	   }
	   if (findEmployee!='t')
	   {
	   gotoxy(30,11);
	   textcolor(YELLOW+BLINK);
	   cprintf("StudentInformation not available. Please modify the search.");
	   textcolor(YELLOW);
	   getch();
	   }
	   break;

  /* To remove entry of an employee from the database*/
  case 4:
	   clrscr();
	   gotoxy(25,5);
	   printf("REMOVE AN STUDENT");
	   gotoxy(25,9);
	   printf("Enter Student Id to Delete: ");
	   scanf("%d", &searchId);
	   findEmployee='f';
	   rewind(db);
           while(fread(&empData,size,1,db)==1)
	   {

	       if (empData.empid==searchId)
	       {
		gotoxy(33,11);
		textcolor(YELLOW+BLINK);
		cprintf("Student Information is Available.");
		textcolor(YELLOW);
		gotoxy(25,13);
		printf("Student name is: %s %s",empData.firstname,empData.lastname);
		findEmployee='t';

	       }
	   }
	   if (findEmployee!='t')
	   {
	   gotoxy(30,11);
	   textcolor(YELLOW+BLINK);
	   cprintf("Student Information not available. Please modify the search.");
	   textcolor(YELLOW);
	   getch();
	   }
	   if (findEmployee=='t')
	   {
	   gotoxy(29,15);
	   printf("Do you want to Delete the Student? (y/n)");
	   confirmDelete=getche();
		if (confirmDelete=='y' || confirmDelete=='Y')
		{
		tempdb=fopen("d:/tempo.dat","wb+");
		rewind(db);
		while(fread(&empData,size,1,db)==1)
			{
			 if (empData.empid!=searchId)
			 {
			 fseek(tempdb,0,SEEK_END);
			 fwrite(&empData,size,1,tempdb);
			 }
			}
		fclose(tempdb);
		fclose(db);
		remove("d:/empbase.dat");
		rename("d:/tempo.dat","d:/empbase.dat");
		db=fopen("d:/empbase.dat","rb+");
		}
	   }
	   break;

  /* To login an employee into the system and record the login date and time*/
  case 5:
	   clrscr();
	   gotoxy(20,4);
	   printf("DAILY TIME RECORDING SYSTEM");
	   gotoxy(20,23);
	   printf("Warning: Please Enter Numeric Values Only.");
	   gotoxy(23,7);
	   printf("Enter Your Id to Login: "******"%d", &searchId);
	   gotoxy(20,23);
	   printf("                                            ");
	   findEmployee='f';
	   rewind(db);
           while(fread(&empData,size,1,db)==1)
	   {
	       if (empData.empid==searchId)
	       {
		gotoxy(23,8);
		printf("Enter Your Password: "******"* ");
		   }
		   pass[6]='\0';
		 while(getch()!=13);

		if (strcmp(empData.password,pass))
		{
		 gotoxy(23,11);
		 textcolor(YELLOW+BLINK);
		 cprintf("You Have Supplied a Wrong Password.");
		 textcolor(YELLOW);
		 findEmployee='t';
		 getch();
		 break;
		}
		gotoxy(23,11);
		textcolor(YELLOW+BLINK);
		cprintf("You have successfully Logged In the System.");
		textcolor(YELLOW);
		gotoxy(23,13);
		printf("Student name: %s %s",empData.firstname,empData.lastname);
		gettime(&now);
		getdate(&today);
		gotoxy(23,14);
		printf("Your LogIn Time: %2d:%2d:%2d",now.ti_min,now.ti_hour,now.ti_sec);
		gotoxy(23,15);
		printf("Your Log In Date: %d/%d/%d",today.da_mon,today.da_day,today.da_year);
		empData.day=today.da_day;
		empData.mon=today.da_mon;
		empData.yr=today.da_year;
		fseek(db,-size,SEEK_CUR);
		empData.loginhour=now.ti_min;
		empData.loginmin=now.ti_hour;
		empData.loginsec=now.ti_sec;
		fwrite(&empData,size,1,db);
		findEmployee='t';
		getch();

	       }
	   }
	   if (findEmployee!='t')
	   {
	   gotoxy(30,11);
	   textcolor(YELLOW+BLINK);
	   cprintf("Student Information is not available.");
	   textcolor(YELLOW);
	   getch();
	   }

	   break;

  /* To logout an employee and record the logout date and time*/
  case 6:

           clrscr();
	   gotoxy(20,4);
	   printf("DAILY EMPLOYEE TIME RECORDING SYSTEM");
	   gotoxy(20,23);
	   printf("Warning: Please Enter Numeric Values Only.");
	   gotoxy(23,7);
	   printf("Enter Your Id to Logout: ");
	   scanf("%d", &searchId);
	   gotoxy(20,23);
	   printf("                                            ");
	   findEmployee='f';
	   rewind(db);
           while(fread(&empData,size,1,db)==1)
	   {
	       if (empData.empid==searchId)
	       {
		gotoxy(23,8);
		printf("Enter Password: "******"* ");
		   }
		   pass[6]='\0';
		 while(getch()!=13);

		if (strcmp(empData.password,pass))
		{
		 gotoxy(30,11);
		 textcolor(YELLOW+BLINK);
		 cprintf("You Have Supplied a Wrong Password.");
		 textcolor(YELLOW);
		 findEmployee='t';
		 getch();
		 break;
		}
		gotoxy(23,11);
		textcolor(YELLOW+BLINK);
		cprintf("You have successfully Logged Out of the System.");
		textcolor(YELLOW);
		gotoxy(23,13);
		printf("Student name is: %s %s",empData.firstname,empData.lastname);
		gettime(&now);
		getdate(&today);
		gotoxy(23,14);
		printf("Your Log Out Time: %2d:%2d:%2d",now.ti_min,now.ti_hour,now.ti_sec);
		gotoxy(23,15);
		printf("Your Log Out Date: %d/%d/%d",today.da_mon,today.da_day,today.da_year);
		fseek(db,-size,SEEK_CUR);
		empData.logouthour=now.ti_min;
		empData.logoutmin=now.ti_hour;
		empData.logoutsec=now.ti_sec;
		fwrite(&empData,size,1,db);
		findEmployee='t';
		getch();

	       }
	   }
	   if (findEmployee!='t')
	   {
	   gotoxy(23,11);
	   textcolor(YELLOW+BLINK);
	   cprintf("Student Information is not available.");
	   textcolor(YELLOW);
	   getch();
	   }

	   break;

  /* Show previous menu*/
  case 9:

	   printf("\n");
	   exit();
	   }
   fclose(db);
   showMenu=1;
   }
 }
void feesmenu()
{	clrscr();
//textbackground(BLACK);
	textcolor(WHITE);
	for(li=30;li<=50;li++)
	{
		textcolor(WHITE);
		gotoxy(li,14);
		delay(10);
		printf("*");
	}
	for(li=50;li>=30;li--)
	{
		textcolor(WHITE);
		gotoxy(li,30);
		delay(10);
		printf("*");
	}
	for(lp=15;lp<30;lp++)
	{
		gotoxy(30,lp);
		delay(10);
		printf("|");
	}
	for(lp=29;lp>=15;lp--)
	{
		gotoxy(50,lp);
		delay(10);
		printf("|");
	}
	gotoxy(15,10);
	textcolor(LIGHTGRAY);
	cprintf("Press the corresponding Keys for the desired action");
	gotoxy(35,16);
	textcolor(BROWN);
	cprintf("F: FEE SLIP");
	gotoxy(35,19);
	textcolor(LIGHTMAGENTA);
	cprintf("M: MODIFY");
	gotoxy(35,22);
	textcolor(LIGHTBLUE);
	cprintf("L: LIST");
	gotoxy(35,25);
	textcolor(LIGHTRED);
	cprintf("H: HELP");
	gotoxy(35,28);
	textcolor(GREEN);
	cprintf("Q: QUIT");
	choice=getch();
	ch=toupper(choice);
	switch(ch)
	{
		case'F':fee.FEE_SLIP();
			break;
		case'M':fee.MODIFICATION();
			break;
		case'L':fee.LIST();
			break;
		case'H':fee.HELP();
			break;
		case'Q':mainmenu();
			break;
		default:gotoxy(33,40);
			cout<<" Illegal Choice  Press any key to return to Main Menu";
			getch();
			feesmenu();
	}
} 	//Fees Menu Function End