Hier hab ich auch mal eine Möglichkeit in C++:
Code:
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
if(argc < 2) {
cout << "Usage: a.out <Buchstabe>" << endl;
return -1;
}
char *fin = argv[1];
int max = (int)*fin - 65;
char alph[] = {'A','B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U','V', 'W', 'X', 'Y', 'Z'};
int k=0,i=0,j=0,p=0,q=max;
while(k <= max) {
for(p=q; p>=0; p--) cout << ' ';
for(i=0; i<=k; i++) cout << alph[i];
for(j=(k-1); j>=0; j--) cout << alph[j];
cout << endl;
k++;
q--;
}
return 0;
} ./a.out G
Code:
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
ABCDEFGFEDCBA