Exemple #1
0
int main(int argc, char **argv){
    Circle circle(1.5);
    Circle circle2 = circle;
    std::cout << circle2.getColor() << std::endl;
    std::cout << circle.getRadius() << std::endl;
    int arr[]={1,2,3,4,5};
    cek(arr);
    int size = (int) sizeof(arr)/sizeof(*arr);
    std::cout << size << std::endl;
    std::string s = "asd";
    char c[] = {'a','b','c'};
    cek2(c);
    return 0;
}
Exemple #2
0
//------------------------------------------------------------------------------
void main()
{
   if((in = fopen("history.txt","w"))== NULL){
			fprintf(stderr,"Cannot open input file.\n");
   }
	fflush(stdin);
	fputs("\t\t <=={ Tampilan Timer }==> ",in);
	fputs("\n\n",in);
	fclose(in);

	tampilan();

balik:
   clrscr();
   printf("\t\t       PILIHAN MENU\n\n");
   printf("\t\t 1. Masukkan Komputer User\n");
   printf("\t\t 2. Lihat Komputer yang Tersedia\n");
   printf("\t\t 3. Lihat Timer\n");
   printf("\t\t 4. Penghentian Komputer User\n");
   printf("\t\t 5. Keluar\n\n");
   printf("\t\t Press Key  ");
   scanf("%d",&pilihan);
//------------------------------------------------------------------------------
tabel1:
   clrscr();
   if(pilihan==1){
      tabell();
      printf("<1>Next  <2>Back    --->  ");
      scanf("%d",&ini);
      if(ini==2){
      	goto balik;
      }
      else if(ini==1){
      	goto neks;
      }
      else{
      	goto tabel1;
      }
   neks:
   	printf("Masukkan baris = ");
   	scanf("%d",&baris);
   	fflush(stdin);
   	printf("Masukkan kolom = ");
   	scanf("%c",&kolom);

   	if(cek_kolom()==0){
      	goto tabel1;
      }
      if(cek()==0){
      	goto tabel1;
      }

   	printf("Masukkan Angka kecuali 0 untuk mengaktifkan komputer = ");
   	scanf("%d",&tabel[baris][klm]);
      satu[baris][kolom] = time(NULL);

      if((in = fopen("history.txt","a"))== NULL){
			fprintf(stderr,"Cannot open input file.\n");
		}
      time(&t);
      konversi();
      fputs(x,in);
		fputs(ctime(&t),in);
      fclose(in);
   	goto balik;
   }
//------------------------------------------------------------------------------
   else if(pilihan==2){
      tabell();
      getch();
      goto balik;
   }
//------------------------------------------------------------------------------
   else if(pilihan==3){
   	system("history.txt");
      goto balik;
   }
//------------------------------------------------------------------------------
   else if(pilihan==4){
   tabel2:
   	clrscr();
      tabell();
      printf("<1>Next  <2>Back    --->  ");
      scanf("%d",&itu);
      if(itu==2){
      	goto balik;
      }
      else if(itu==1){
      	goto next;
      }
      else{
      	goto tabel2;
      }
   next:
   	printf("Masukkan baris = ");
   	scanf("%d",&baris);
   	fflush(stdin);
   	printf("Masukkan kolom = ");
   	scanf("%c",&kolom);

   	if(cek_kolom()==0){
      	goto tabel2;
      }
      if(cek1()==0){
      	goto tabel2;
      }
   lagi:
   	printf("Masukkan Angka [0] untuk menonaktifkan komputer = ");
   	scanf("%d",&tabel[baris][klm]);
      if(tabel[baris][klm]!=0){
      	goto lagi;
      }
      dua = time(NULL);
      PlaySound(TEXT("SMSVoice.wav"), NULL, SND_FILENAME);
//------------------------------------------------------------------------------
		jm = difftime(dua,satu[baris][kolom]);
		jam = jm / 3600;
      menit1 = jm % 3600;
      menit = menit1 / 60;
      detik1 = jm % 3600;
      detik = detik1 % 60;
      printf("Lama Waktu    = %d jam %d menit %d detik\n",jam,menit,detik);

      if(difftime(dua,satu[baris][kolom]) <= 500){
      	total = 500;
      }
      else if(difftime(dua,satu[baris][kolom]) > 500 && difftime(dua,satu[baris][kolom]) < 1800){
      	total = 0.5 * tarif;
      }
      else if(difftime(dua,satu[baris][kolom]) >= 1800 && difftime(dua,satu[baris][kolom]) <= 3600){
      	total = tarif;
      }
      else{
      	total = difftime(dua,satu[baris][kolom]) / 3600 * tarif;
      }
      printf("Total Bayar   = %g\n",total);
      printf("Masukkan Uang = ");scanf("%f",&bayar);
      kembalian = bayar - total;
      printf("Kembalian     = %g",kembalian);
      getch();
   	goto balik;
   }
//------------------------------------------------------------------------------
   else if(pilihan==5){
   	exit(1);
   }
   else{
   	goto balik;
   }
}