Anonymous Anonymous - 30 days ago
476 0

asd

C

C vs Python

Python:
a = int(input())
b = int(input())
c = int(input())
d = int(input())

width = len(str(b*d)) + 1
print(" "*width, end='')
for j in range (a, b+1):
  print(" "*(width - len(str(j))) + str(j), end="")
print()
for i in range (c, d+1):
  print(" "*(width - len(str(i))) + str(i), end ="")
  for j in range (a, b+1):
    print(" "*(width - len(str(i*j))) + str(i*j), end ="")
  print()

C:
#include <stdio.h>

int main(int argc, char **argv) {
  int i = 0;
  int i2 = 0;
  int i3 = 0;
  int number = 0;
  int   aMin      = atoi(argv[1]);
  int   aMax      = atoi(argv[2]) + 1;
  int   aWidth    = aMax - aMin;
  int   bMin      = atoi(argv[3]);
  int   bMax      = atoi(argv[4]) + 1;
  int   tempWidth = 0;
  int   width     = (bMax*aMax);
    int wTimes    = 0;
    while((width / 10) != 0) {
      width = width / 10;
      wTimes++;  
    }
  width = wTimes + 1;
  
  /* Ekan rivin ensimmäiset välit */
  for (i = 0; i < width+1; i++) {
  printf(" ");
  }
  for (i = aMin; i < aMax; i++) {
    number = i;
    while ((number / 10) != 0)  {
        number = number / 10;
        tempWidth++;
      }
    for (i2 = 0; i2 < (width-tempWidth); i2++) { 
        printf(" ");
    }
    tempWidth = 0;
    printf("%d", i);
  }
  printf("\n");
  
  /* Muut rivit */
  for (i = bMin; i < bMax; i++) {
    number = i;
      while ((number / 10) != 0)  {
        number = number / 10;
        tempWidth++;
      } 
      for (i3 = 0; i3 < (width-tempWidth); i3++) { 
        printf(" "); 
      }
      tempWidth = 0;
      number = i;
      printf("%d", number);
    for (i2 = aMin; i2 < aMax; i2++) {
      number = i * i2;
      while ((number / 10) != 0)  {
        number = number / 10;
        tempWidth++;
      } 
      for (i3 = 0; i3 < (width-tempWidth); i3++) { 
        printf(" "); 
      }
      tempWidth = 0;
      number = i * i2;
      printf("%d", number);
    }
    printf("\n");
  }
  
  return 0;
}