All pastes #778553 Raw Edit

Something

public cpp v1 · immutable
·published 2007-11-17 18:24 UTC
rendered paste body
#include <stdio.h>#include <iostream>#include <fstream>using namespace std;class Cmap{	char m[10][10];	public:	char get (int x=0, int y=0){		return((((x<0)||(x>9))||((y<0)||(y>9)))?'X':m[x][y]);	}	Cmap(int i=0){		for(int o=0;o<10;o++)			for(int u=0;u<10;u++)				m[o][u]='.';	};		ostream& trk(ostream& os, int b=0){		for(int o=0-b;o<10+b;o++){			for(int u=0-b;u<10+b;u++)				os << get(o,u);			os << endl;		}		return os;	}		void read(ifstream& is){		for(int o=0-b;o<10+b;o++){			for(int u=0-b;u<10+b;u++)				vread(sf,"%d",&m[o][u]);		}	}};typedef class Cmap Cmap;ostream& operator << (ostream& os, Cmap& m){	for(int o=0;o<10;o++){		for(int u=0;u<10;u++)				os << m.get(o,u);		os << endl;	}	return os;}int main (void){	//FILE *sf,*vf;	ifstream sf;	ofstream vf;	//sf=fopen("laev.sis","r");	//vf=fopen("laev.val","w");	sf.open("laev.sis");	char m[9][9];	if( !sf ) {		cerr << "Error opening input stream" << endl;		return 1;	}	else{		sf.read((&m), sizeof(m) );		cout<< m[1][1] <<endl;	}	int i, j;	Cmap a;	a.trk(cout,1);	cout << a;		//fclose(sf);	//fclose(vf);}