fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int Choice, Mission1, Vission1;
  5.  
  6. printf("Choose the Vision or Mission (type 1 or 2): \n"
  7. "1. Vision\n"
  8. "2. Mission\n"
  9. "Please enter the digit: ");
  10. scanf("%d", &Choice);
  11.  
  12. if (Choice == 1) {
  13. printf("Learn about School's Vision or Computer Studies (Type 1 or 2) \n"
  14. "1. School \n"
  15. "2. Computer Studies \n"
  16. "Please enter the digit: ");
  17. scanf("%d", &Vission1);
  18.  
  19. if (Vission1 == 1) { //School's Vission
  20. printf(" OUR LADY OF FATIMA UNIVERSITY VISION \n"
  21. "A premier inclusive university of choice aspiring to improve man as man by developing individuals through a legacy of \n"
  22. " excellent \n"
  23. " education and compassionate value formation.\n");
  24. }
  25. else if (Vission1 == 2) { //Computer Studie's Vission
  26. printf(" COLLEGE OF COMPUTER STUDIES VISION\n"
  27. "We are committed to provide accessible, responsive, and quality\n"
  28. "Information Technology Education (ITE) programs and to become\n"
  29. "the Institution of choice in producing competent and responsible IT\n"
  30. "professionals who are sensitive to the needs and demands of the\n"
  31. " industry.\n");
  32. }
  33. else {
  34. printf("\nInvalid choice. Please type 1 or 2.\n");
  35. }
  36. }
  37. else if (Choice == 2) { // THE MISSION
  38. printf("Learn about School's Mission or Computer Studies (Type 1 or 2) \n"
  39. "1. School \n"
  40. "2. Computer Studies \n"
  41. "Please enter the digit: ");
  42. scanf("%d", &Mission1);
  43. if (Mission1 == 1) {
  44. printf("OUR LADY OF FATIMA UNIVERSITY MISSION\n"
  45. "The Our Lady of Fatima University, together with Fatima Medical Science\n"
  46. "Foundation, Inc., is dedicated to the improvement of man as man through holistic\n"
  47. "formation of individuals imbued with knowledge, skills and virtues.");
  48. }
  49. else if (Mission1 == 2) {
  50. printf(" COLLEGE OF COMPUTER STUDIES MISSION\n"
  51. " The College of Computer Studies aims to provide innovative and quality\n"
  52. " instruction to the advancement of technology intends to develop an\n"
  53. "entrepreneurial learning environment towards sustainability and growth; and develops responsible and morally upright\n"
  54. " citizens.");
  55. }
  56. else {
  57. printf("\nInvalid choice. Please type 1 or 2.\n");
  58.  
  59. }
  60. }
  61. else {
  62. printf("\nInvalid choice. Please type 1 or 2.\n");
  63. }
  64.  
  65. return 0;
  66. }
  67.  
Success #stdin #stdout 0s 5284KB
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
Choose the Vision or Mission (type 1 or 2): 
1. Vision
2. Mission
Please enter the digit: 
Invalid choice. Please type 1 or 2.