Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******EJERCICIO 6_B*****/
- #include<stdio.h>
- #include<math.h>
- int Cumple(int alto, int ancho, char **matriz);
- int main(){
- int celda=0;
- int ancho,alto;
- char M[100][100];
- while(1){
- scanf("%d %d",&ancho,&alto);
- if((!alto)||(!ancho))
- break;
- for(int i=0; i<=alto; i++)
- for(int j=0; j<=ancho; j++)
- scanf("%c",&M[i][j]);
- celda = Cumple(alto, ancho, M);
- printf("%d",celda);
- }
- return 0;
- }
- int Cumple(int alto, int ancho, char **matriz){
- int cont = 0, celda= 0;
- for(int i=0; i<=alto; i++){
- for(int j=0; j<=ancho; j++){
- if(matriz[i][j]==45){
- if(matriz[i-1][j-1]==42)
- cont++;
- if(matriz[i-1][j]==42)
- cont++;
- if(matriz[i-1][j+1]==42)
- cont++;
- if(matriz[i][j-1]==42)
- cont++;
- if(matriz[i+1][j-1]==42)
- cont++;
- if(matriz[i+1][j]==42)
- cont++;
- if(matriz[i+1][j+1]==42)
- cont++;
- if(matriz[i][j+1]==42)
- cont++;
- }
- if(cont>=6)
- celda++;
- cont=0;
- }
- }
- return celda;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement