removido
(usa Nenhuma)
Enviado em 29/03/2012 - 13:00h
um exemplo...
#include <iostream>
#include <fstream>
using namespace std;
int main( int argc, char** argv )
{
const int MAX=10; // Define o tamanho da matriz
char matriz[MAX][MAX]; // Cria a matriz
// Preenche a matriz
for (int i=0; i<MAX; i++)
{
for(int j=0; j<MAX; j++)
{
matriz[ i ][ j ] = 'C';
}
}
ofstream arq("arquivo.html");
string buff = "<html>";
arq.write( buff.c_str( ), buff.length( ) );
buff = "<head><title>Matriz</title></head>";
arq.write( buff.c_str( ), buff.length( ) );
buff = "<body>";
arq.write( buff.c_str( ), buff.length( ) );
buff = "<center><h3>Matriz gerada dinamicamente</h3><center>";
arq.write( buff.c_str( ), buff.length( ) );
buff = "<table border=1>";
arq.write( buff.c_str( ), buff.length( ) );
buff = "";
for ( int i=0; i<MAX; i++ )
{
buff += "<tr>";
for ( int j=0; j<MAX; j++ )
{
buff += "<td> ";
buff += matriz[i][j];
buff += " </td>";
}
buff += "</tr>";
}
arq.write( buff.c_str( ), buff.length( ) );
buff = "</table>";
arq.write( buff.c_str( ), buff.length( ) );
buff = "</body>";
arq.write( buff.c_str( ), buff.length( ) );
buff = "</html>";
arq.write( buff.c_str( ), buff.length( ) );
arq.flush( );
arq.close( );
return EXIT_SUCCESS;
}