Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #define MAXIMUM_ELEMENTS 100
- int main(){
- unsigned int k;
- unsigned int j,h,m,n;
- printf("Inserisci la lunghezza del codice: "); scanf("%u",&k); fflush(stdin);
- unsigned int* Num=(unsigned int*) malloc(MAXIMUM_ELEMENTS*sizeof(unsigned int));
- printf("\nInserisci i numeri che compongono il codice (X per terminare): ");
- unsigned int i=0;
- while(1){
- char Temp;
- scanf("%c",&Temp); fflush(stdin);
- if(Temp=='x' || Temp=='X') break;
- if(Temp<'0' || Temp>'9'){
- printf("\nNon Valido!");
- continue;
- }
- Num[i++]=Temp-'0';
- }
- if(i==0) printf("Nessun Elemento Inserito!");
- else{
- unsigned int NumRighe=pow((double)i,(int)k);
- unsigned int** Result=(unsigned int**) malloc(k*sizeof(unsigned int*));
- for(j=0;j<k;j++){
- Result[j]=(unsigned int*) malloc(sizeof(unsigned int)*(NumRighe));
- for(h=0;h<NumRighe;){ //Per ogni Colonna
- for(n=0;n<i;n++){ //Per Ogni numero che compone il codice
- for(m=0;m<pow((double)i,(int)j);m++){
- Result[j][h++]=Num[n];
- }
- }
- }
- }
- for(h=0;h<NumRighe;h++){
- printf("\n");
- for(j=k-1;;j--) {
- printf("%u",Result[j][h]);
- if(j==0) break;
- }
- }
- for(j=0;j<k;j++) free(Result[j]);
- free(Result);
- }
- free(Num);
- printf("\n"); scanf("%u",&k); //Mette in pausa
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement