fork download
  1. def show_distribution_factor(procedure, girder_type):
  2. if procedure == "Moment" and girder_type == "Interior":
  3. print("Moment - Interior Girder (Method 2):")
  4. print("1. One Lane Loaded: DF = 0.06 + (S / 14)^0.4 * (S / L)^0.3 * (Kg / (12 * Lt^3))^0.1")
  5. print("2. Two or More Lanes Loaded: DF = 0.075 + (S / 9.5)^0.6 * (S / L)^0.2 * (Kg / (12 * Lt^3))^0.1")
  6. elif procedure == "Moment" and girder_type == "Exterior":
  7. print("Moment - Exterior Girder (Method 2):")
  8. print("1. g = e * g_interior")
  9. print("2. e = 0.77 + d_e / 9.1 (Equation 3)")
  10. print("3. Method 1: (a + 3) / L * multiple presence factor")
  11. print("4. Method 3: R = (Nc / Nb) + (X_ext * Σe / Σx^2) * multiple presence factor")
  12. elif procedure == "Shear" and girder_type == "Interior":
  13. print("Shear - Interior Girder (Method 2):")
  14. print("1. One Lane Loaded: DF = 0.36 + (S / 25.0)")
  15. print("2. Two or More Lanes Loaded: DF = 0.2 + (S / 12.0) - (S / 35.0)^2")
  16. elif procedure == "Shear" and girder_type == "Exterior":
  17. print("Shear - Exterior Girder (Method 2):")
  18. print("1. g = e * g_interior")
  19. print("2. e = 0.6 + d_e / 10 (Equation 6)")
  20. print("3. Method 1: (a + 3) / L * multiple presence factor")
  21. print("4. Method 3: R = (Nc / Nb) + (X_ext * Σe / Σx^2) * multiple presence factor")
  22. else:
  23. print("Invalid input, please choose correct options.")
  24.  
  25. def run_distribution_factor_program():
  26. print("Welcome to the Distribution Factor Calculation Program")
  27.  
  28. procedure = input("Enter 'Moment' or 'Shear': ")
  29. girder_type = input("Enter 'Interior' or 'Exterior' girder: ")
  30.  
  31. show_distribution_factor(procedure, girder_type)
  32.  
  33. # Run the program
  34. run_distribution_factor_program()
  35.  
Success #stdin #stdout 0.03s 9728KB
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
Welcome to the Distribution Factor Calculation Program
Enter 'Moment' or 'Shear': Enter 'Interior' or 'Exterior' girder: Invalid input, please choose correct options.