Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main()
  5. {
  6. FILE *fin = fopen("input.txt", "r");
  7. FILE *fout =fopen("output.txt", "w");
  8.  
  9. int n,m,sum=0,check=0;
  10.  
  11. fscanf(fin,"%d%d",&n,&m);
  12.  
  13.  
  14. char *mushrooms1 = (char*)malloc(sizeof(char) * m);
  15. char *mushrooms2 = (char*)malloc(sizeof(char) * m);
  16. fgets(mushrooms1,m,fin);
  17. for (int i=1;i<n;i++)
  18. {
  19. fgets(mushrooms2,m,fin);
  20. for (int j=0;j<m;j++)
  21. {
  22. if ((mushrooms1[j]=='*') && (mushrooms2[j]=='#'))
  23. {
  24. sum++;
  25. while ((mushrooms2[j++]=='#') && (j!=m-1));
  26. }
  27. }
  28. for (int j=0;j<m;j++)
  29. {
  30. mushrooms1[j]=mushrooms2[j];
  31. }
  32. }
  33.  
  34. fprintf(fout,"%d",sum);
  35.  
  36. fclose(fin);
  37. fclose(fout);
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement