예제 #1
0
// gcc -g answer02.c -DMYTEST && ./a.out
int main()
{
   int value = 10;
   //partitionAll(value);
   //partitionIncreasing(value);
   //partitionDecreasing(value);
   //partitionOdd(value);
   //partitionEven(value);
   partitionOddAndEven(value);
   //partitionPrime(value);
   
   return;
}
예제 #2
0
int main(int argc, char * * argv)
{

  printf("input file format:\n<method> <value to partition>\n\n");
  printf("methods:\n1. All\n2. Increasing\n3. Decreasing\n4. Odd\n5. Even\n6. OddAndEven\n7. Prime\n\n");

  if (argc < 2)
    {
      printf("usage: ./pa04 <input file>\n");
      return EXIT_FAILURE;
    }

  FILE* fin = fopen(argv[1], "r");
  if (!fin)
    {
      printf("file error\n");
      return EXIT_FAILURE;
    }

  int val = 1;
  int method = 0;
  fscanf(fin, "%d", &method);
  fscanf(fin, "%d", &val);

  printf("current method: %d\ncurrent value: %d\nStart Partitioning...\n", method, val);

  switch(method)
    {
    case 1: partitionAll(val);
      break;
    case 2: partitionIncreasing(val);
      break;
    case 3: partitionDecreasing(val);
      break;
    case 4: partitionOdd(val);
      break;
    case 5: partitionEven(val);
      break;
    case 6: partitionOddAndEven(val);
      break;
    case 7: partitionPrime(val);
      break;
    }

  fclose(fin);

  return EXIT_SUCCESS;
}
예제 #3
0
int main(int argc, char * * argv)
{
	if (argc != 3)
	{
		return EXIT_SUCCESS;
	}

	if (!strcmp(argv[1], "partitionAll"))
	{
		partitionAll(atoi(argv[2]));
	}

	if (!strcmp(argv[1], "partitionIncreasing"))
	{
		partitionIncreasing(atoi(argv[2]));
	}

	if (!strcmp(argv[1], "partitionDecreasing"))
	{
		partitionDecreasing(atoi(argv[2]));
	}

	if (!strcmp(argv[1], "partitionOdd"))
	{
		partitionOdd(atoi(argv[2]));
	}

	if (!strcmp(argv[1], "partitionEven"))
	{
		partitionEven(atoi(argv[2]));
	}

	if (!strcmp(argv[1], "partitionOddAndEven"))
	{
		partitionOddAndEven(atoi(argv[2]));
	}

	if (!strcmp(argv[1], "partitionPrime"))
	{
		partitionPrime(atoi(argv[2]));
	}

	return EXIT_SUCCESS;
}
예제 #4
0
int main(void)
{
	//char *String[50] = "hello";
	int Num = 2;
	
	while (Num - 1)
	{
		printf("Enter a number to partition: ");
		scanf("%i",&Num);
		printf("\n");
		partitionAll(Num);
	}
	Num = 2;
	while (Num - 1)
	{
		printf("Enter a number to partition increasing: ");
		scanf("%i",&Num);
		printf("\n");
		partitionIncreasing(Num);
	}
	
	Num = 2;
	while (Num - 1)
	{
		printf("Enter a number to partition decreasing: ");
		scanf("%i",&Num);
		printf("\n");
		partitionDecreasing(Num);
	}

	Num = 2;
	while (Num - 1)
	{
		printf("Enter a number to partition even: ");
		scanf("%i",&Num);
		printf("\n");
		partitionEven(Num);
	}		


	Num = 2;
	while (Num - 1)
	{
		printf("Enter a number to partition Odd: ");
		scanf("%i",&Num);
		printf("\n");
		partitionOdd(Num);
	}		

	Num = 2;
	while (Num - 1)
	{
		printf("Enter a number to partition even/Odd: ");
		scanf("%i",&Num);
		printf("\n");
		partitionOddAndEven(Num);
	}		

	Num = 2;
	while (Num - 1)
	{
		printf("Enter a number to partition Prime: ");
		scanf("%i",&Num);
		printf("\n");
		partitionPrime(Num);
	}		
		
	return (EXIT_SUCCESS);
}