#include <iostream>

using namespace std;

int count(int array[])
{
  int i = 0;
  while (array[i] >= 0) {
    i++;
  }
  return i;
}

int biggest(int array[])
{
  int i, b = 0;
  for (i = 1; i < count(array); i++) {
    if (array[i] > array[b]) {
      b = i;
    }
  }
  return b;
}


void horiz(int vals[])
{
  int i, j;
  for (i = 0; i < count(vals); i++) {
    for (j = 1; j <= vals[i]; j++) {
      cout << "X";
    }
    cout << endl;
  }
}

void vert(int vals[])
{
  int i, j, b = biggest(vals);
  for (i = vals[b]; i > 0; i--) {
    for (j = 0; j < count(vals); j++) {
      if (vals[j] >= i) {
        cout << "X";
      } else {
        cout << " ";
      }
    }
    cout << endl;
  }
}

int main(void)
{
  int i, j = 0, vals[100];
  char t;
  bool cont;
  do {
    cout << "Tal " << j+1 << ": ";
    cin >> i;
    vals[j++] = i;
  } while (i >= 0);
  do {
    cout << endl << "(H)orisontellt eller (V)ertikalt diagram? ";
    cin >> t;
    cout << endl;
    cont = false;
    switch (tolower(t)) {
      case 'h': horiz(vals); break;
      case 'v': vert(vals); break;
      default: cout << "Felaktig inmatning!" << endl; cont = true;
    }
  } while (cont);
  cout << endl;
  return 0;
}

