Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- FILE *fin = fopen("input.txt", "r");
- FILE *fout =fopen("output.txt", "w");
- int n,m,sum=0,check=0;
- fscanf(fin,"%d%d",&n,&m);
- char *mushrooms1 = (char*)malloc(sizeof(char) * m);
- char *mushrooms2 = (char*)malloc(sizeof(char) * m);
- fgets(mushrooms1,m,fin);
- for (int i=1;i<n;i++)
- {
- fgets(mushrooms2,m,fin);
- for (int j=0;j<m;j++)
- {
- if ((mushrooms1[j]=='*') && (mushrooms2[j]=='#'))
- {
- sum++;
- while ((mushrooms2[j++]=='#') && (j!=m-1));
- }
- }
- for (int j=0;j<m;j++)
- {
- mushrooms1[j]=mushrooms2[j];
- }
- }
- fprintf(fout,"%d",sum);
- fclose(fin);
- fclose(fout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement