Advertisement
nRikee

Apagar PC v.1.1

Jan 3rd, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7.     int s;
  8.     int x, cifras, buffer, tiempo;
  9.     char apagar[50] = "shutdown /s /t ";
  10.     char apagar_2[20] = "";
  11.  
  12.     do{
  13.         system("cls");
  14.         printf("Apagar PC 1.0\nAutor: @nRikee93\n\nElige:\n1.Apagar\n2.Cancelar apagado.\n_");
  15.         scanf("%d",&s);
  16.     } while (s==1&&s==2);
  17.  
  18.     if(s==1){
  19.  
  20.         do{
  21.             system("cls");
  22.             printf("Apagar PC 1.0\nAutor: @nRikee93\n\nElige el retardo:\n1.Un minuto\n2.Diez minutos\n3.Media hora\n4.Una hora\n5.Dos horas\n6.Cinco horas\n7.Personalizado\n 0.Cancelar\n\n_");
  23.             scanf("%d",&s);
  24.         } while(s<0||s>7);
  25.  
  26.         switch(s)
  27.         {
  28.             case 1: system("shutdown /s /t 60");
  29.                     break;
  30.             case 2: system("shutdown /s /t 600");
  31.                     break;
  32.             case 3: system("shutdown /s /t 1800");
  33.                     break;
  34.             case 4: system("shutdown /s /t 3600");
  35.                     break;
  36.             case 5: system("shutdown /s /t 7200");
  37.                     break;
  38.             case 6: system("shutdown /s /t 18000");
  39.                     break;
  40.             case 7:
  41.                 printf("Horas: ");
  42.                 scanf("%d",&buffer);
  43.                 tiempo = buffer*3600;
  44.                 printf("Minutos: ");
  45.                 scanf("%d",&buffer);
  46.                 tiempo = tiempo+buffer*60;
  47.                 printf("Segundos: ");
  48.                 scanf("%d",&buffer);
  49.                 tiempo = tiempo+buffer;
  50.                 // Numero de cifras
  51.                 x=0;
  52.                 cifras=1;
  53.                 while ( ((int)(tiempo/pow(10,x)))!=0 ) x++;
  54.                 cifras = x;
  55.                 // Asignar
  56.                 x=0;
  57.                 while( cifras-x!=0){
  58.                     apagar_2[cifras-x-1]= 48 + ((tiempo%(int)pow(10,x+1))/((int)pow(10,x)));
  59.                     x++;
  60.                 }
  61.                 strcat(apagar,apagar_2);
  62.                 system(apagar);
  63.             case 8: break;
  64.         }
  65.     }
  66.     if(s==0||s==2){
  67.         system("shutdown /a");
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement