9511_workbook

solved exercises from algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
guia03/ex27.c (416B)
   1 #include <stdio.h>
   2 #include <stdlib.h>
   3 
   4 #define MAX_LEN 100
   5 
   6 int main ( void ) {
   7 
   8     char str[MAX_LEN], buffer[MAX_LEN];
   9     int i, j, num;
  10 
  11     if(fgets(str, MAX_LEN, stdin) == NULL)
  12         return 1;
  13 
  14     if(fgets(buffer, MAX_LEN, stdin) == NULL)
  15         return 1;
  16 
  17     num = atoi(buffer);
  18 
  19     for(i = 0; str[i] != '\0'; i++)
  20         if(str[i] == '\n')
  21             i++;
  22             for(j = 0; j <= num; j++)
  23                 str[i + j] = ' ';
  24 
  25     printf("%s\n", str);
  26     return 0;
  27 }