Advertisement
Jordimario

inserzionePacchetti

Nov 11th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.04 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define MAX 100
  4. #include <string.h>
  5.  
  6. void checksum(char str[]);
  7.     void fillBlank(char s[]);
  8.  
  9. int main()
  10. {
  11.     char stringa[MAX];
  12.     printf("Hello world!\n");
  13.     checksum(gets(stringa));
  14.  
  15.     return 0;
  16. }
  17.  
  18. void checksum(char str[]){
  19.     int i=0;///indice stringa
  20.     int j;///indice pacchetto
  21.     int pack;///variabile per il numero di pacchetti
  22.     char mat[MAX][MAX];///matrice dati
  23.  
  24.     fillBlank(str);
  25.  
  26.     pack=strlen(str)/10;
  27.  
  28.         for(j=0;j<pack;j++){
  29.                 for(i=0;i<10;i++){
  30.                     mat[i][j]=str[i+10*j];
  31.                 }
  32.         }
  33.  
  34.         for(j=0;j<pack;j++){
  35.                 printf("\nS%d:",j);
  36.                 for(i=0;i<10;i++){
  37.                    printf("%c",mat[i][j]);
  38.                 }
  39.  
  40.         }
  41.  
  42.  
  43. }
  44.  
  45.     void fillBlank(char s[]){
  46.         while(strlen(s)%10!=0){///eseeguira un ciclo finche i caratteri non sono divisibili per 10 senza resto
  47.             strcat(s," "); ///inserisce uno spazio per aggiungere un carattere
  48.         }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement