Einzelnen Beitrag anzeigen
Alt 23.05.09, 12:27   #17 (permalink)
Alive
 
Registriert seit: 02.10.08
Alive Leistung: Facit NTK
Likes: 0
Standard

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
Alive ist offline   Mit Zitat antworten
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61