Tuesday, February 26, 2008

pointer

#include
#include
#include
using namespace std;
int main()
{
int* a = NULL; // Pointer to int, initialize to nothing. int flag,tav=0; int i=1; int j=0; int f,c,f2,n; int s=0; string m[9999];
int max=0;
while(i!=0) { cin>>i>>j;
if((i==0)or(j==0)) break; // a = new int[i][j]; // Allocate n ints and save ptr in a.
for (f=1; f<=i; f++) cin>>m[f]; } for (f=0; f<=i; f++) for (c=0; c<=j; c++) { // if (m[f][c]=="*") cout<<"here is stars : : : " <<"*"<=1) { if (m[f-1][c]=='*') s+=1; if (c-1>=1) if (m[f-1][c-1]=='*') s+=1; if (c+1<=j) if (m[f-1][c+1]=='*') s+=1; } if (f+1<=i) { if (m[f+1][c]=='*') s+=1; if (c-1>=1) if (m[f+1][c-1]=='*') s+=1; if (c+1<=j) if (m[f+1][c+1]=='*') s+=1; } if (c-1>=1) if(m[f][c-1]=='*') s+=1; if (c+1<=j) if(m[f][c+1]=='*') s+=1; */ cout<<"S is : : : "<



// delete [] a; // When done, free memory pointed to by a.// a = NULL; // Clear a to prevent using invalid memory reference.