fork download
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7. int i,j;
  8. int const n=3;
  9. int const m=4;
  10. int a[m][n]={{2015,8000,80},
  11. {2014,6000,45},
  12. {2011,3000,65},
  13. {2019,1999,20}};
  14. char t[]="---------------------------------------------------------";
  15. cout<<setw(33)<<" BUY OR RENT A CAR"<<endl;
  16. cout<<t<<endl;
  17. cout<<setw(6)<<"model"<<setw(9)<<"year"<<setw(14)<<"sale price"<<setw(8)<<"rent "<<endl;
  18. cout<<t<<endl;
  19. string modeli[m]={"BMW","AUDI","FIAT","HONDA"};
  20.  
  21. for(i=0;i<m;i++){
  22. cout<<setw(5)<<modeli[i];
  23. for(j=0;j<n;j++){
  24. cout<<setw(10)<<a[i][j];
  25.  
  26. }
  27. cout<<"\n";
  28. }
  29. cout<<t;
  30. cout<<"\n\n";
  31.  
  32.  
  33.  
  34. //seleketimi i makines dhe cimi i saj per rent ose buy dalja nga programi ; (a.s)
  35. string str1;
  36. string str2;
  37. string str3;
  38. int ucar;
  39. int s;
  40. fillim1:
  41. cout<<"What service do you want buy or rent ? "<<endl;
  42. cin>>str1;
  43. if(str1=="buy"){
  44. goto fillim;
  45. }
  46. else if(str1=="rent"){
  47. goto fillim;
  48. }
  49.  
  50. else if(str1=="Buy"){
  51. goto fillim;
  52. }
  53. else if(str1=="BUY"){
  54. goto fillim;
  55. }
  56.  
  57. else{
  58. cout<<" WE CANT FIND THIS SERVICE "<<endl;
  59. cout<<"DO WANT TO TRY AGAIN "<<endl;
  60. cin>>str3;
  61. if(str3=="yes"){
  62. goto fillim1;
  63. }
  64. else if(str3=="Yes"){
  65. goto fillim1;
  66. }
  67. else if(str3=="YES"){
  68. goto fillim1;
  69. }
  70. else if(str3=="no"){
  71. goto fund;
  72. }
  73. else if(str3=="No"){
  74. goto fund;
  75. }
  76. else {
  77. goto fund;
  78.  
  79. }
  80.  
  81.  
  82.  
  83. cout<<"\n";
  84.  
  85. fillim:
  86. cout<<"what car do you want ?"<<endl;
  87. cin>>str2;
  88. cout<<"\n";
  89.  
  90.  
  91. if(str1=="buy"){
  92. cout<<"contact for more +355 67 713 4666"<<endl;
  93. }
  94. else if(str1=="Buy"){
  95. cout<<"contact for more +355 67 713 4666"<<endl;
  96. }
  97. else if(str1=="BUY"){
  98. cout<<"contact for more +355 67 713 4666"<<endl;
  99. }
  100. else if (str1=="rent"){
  101. cout<<" how many days do you want to use the car ?"<<endl;
  102. cin>>ucar;
  103.  
  104. for(i=0;i<m;i++){
  105. if(str2==modeli[i]){
  106. s=ucar*a[i][2];
  107. cout<<t<<endl;
  108. cout<<"THE TOTAL RENT BILL IS "<<s<<"$"<<endl;
  109. cout<<t<<endl;
  110. }
  111. }
  112. }
  113. fund:
  114. cout<<t;
  115. cout<<"\n";
  116. cout<<"GOODBYE HAVE A NICE DAY SIR! "<<endl;
  117. cout<<t<<endl;
  118. return 0;
  119. }
  120. }
Success #stdin #stdout 0s 5300KB
stdin
/*  Berechnung des Hamming-Abstandes zwischen zwei 128-Bit Werten in 	*/
/*	einer Textdatei. 													*/
/*  Die Werte müssen auf einer separaten Zeile gespeichert sein			*/
/* 																		*/
/*	Erstellt: 17.5.2010													*/
/*  Autor: Thomas Scheffler												*/

#include <stdio.h>
#include <stdlib.h>

#define ARRAY_SIZE 32

unsigned Hamdist(unsigned x, unsigned y)
{
  unsigned dist = 0, val = x ^ y;
 
  // Count the number of set bits
  while(val)
  {
    ++dist; 
    val &= val - 1;
  }
 
  return dist;
}



int main (void)
{
	char hex;
	int i;
	int a[ARRAY_SIZE];
	int b[ARRAY_SIZE];
	int hamDist = 0;
	FILE* fp;
	
	//Arrays mit 0 initialisieren
	for (i = 0; i < ARRAY_SIZE; ++i)
	{
  		a[i] = 0;
  		b[i] = 0;
	}

	
	fp = fopen("hex.txt","r");
	if (fp == NULL) 
	{
		printf("Die Datei hex.txt wurde nicht gefunden!");
		exit(EXIT_FAILURE);
	}

	i=0;
	printf("1.Zeile einlesen.\n");

 	while((hex=fgetc(fp))!='\n' && hex != EOF)
    {
        a[i]=strtol(&hex,0,16);
		i++;
    }
	i=0;
	printf("2.Zeile einlesen.\n");

 	while((hex=fgetc(fp))!='\n' && hex != EOF)
    {
    	b[i]=strtol(&hex,0,16);
        i++;
    }
	fclose(fp);

	printf("Hamming-Abweichung pro Nibble:\n");
	for (i = 0; i < ARRAY_SIZE; ++i)
	{
		printf ("%i\t%i\t%i\n",a[i],b[i],Hamdist(a[i],b[i]));
		hamDist += Hamdist(a[i],b[i]);
	}
	printf ("\nHamming-Abweichung der Hash-Werte:%d\n",hamDist);
}

stdout
                BUY OR RENT A CAR
---------------------------------------------------------
 model     year    sale price   rent 
---------------------------------------------------------
  BMW      2015      8000        80
 AUDI      2014      6000        45
 FIAT      2011      3000        65
HONDA      2019      1999        20
---------------------------------------------------------

What service do you want buy or rent  ? 
 WE  CANT FIND THIS SERVICE 
DO WANT TO TRY AGAIN   
---------------------------------------------------------
GOODBYE HAVE A NICE DAY SIR! 
---------------------------------------------------------