ajia. Si pones una música tétrica ya es un puntazo.
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú/*Text based web browser*/
#include <string>
#include <iostream>
#include <boost/asio.hpp>
using namespace std;
string get_formated_web(string);
string getWeb(string);
string getPage(string);
int main(int argv, char **argc){
if(argv==2){
string web=getWeb(string(argc[1]));
cout<<"web: "<<web<<endl;
string page=getPage(string(argc[1]));
cout<<"page: "<<page<<endl;
boost::asio::ip::tcp::iostream stream;
stream.expires_from_now(boost::posix_time::seconds(60));
stream.connect(web, "http");
stream << "GET "<<page<<" HTTP/1.0\r\n";
stream << "Host: "<< web <<"\r\n";
stream << "Accept: */*\r\n";
stream << "Connection: close\r\n\r\n";
stream.flush();
stringstream codestream;
codestream<<stream.rdbuf();
string htmlsource( codestream.str() );
string formatedweb=get_formated_web(htmlsource);
std::cout << formatedweb;
}
else{
cout<<"Wrong arguments."<<endl
<<"Usage: http www.webpage.com"<<endl;
}
}
/* given: www.webpage.com/page.html */
/* returns: www.webpage.com */
string getWeb(string a){
string web;
for(int i=0;i<a.size();i++){
if(a[i]==':'){
web+=a[i];
if(i+2<a.size()){
if(a[i+1]=='/' && a[i+2]=='/'){
web+="//";
i+=2;
}
}
}
else if(a[i]=='/'){
return web;
}
else{
web+=a[i];
}
}
return web;
}
/* given: www.webpage.com/page.html */
/* returns: /page.html */
string getPage(string a){
string page;
bool found=false;
for(int i=0;i<a.size();i++){
if(found){
page+=a[i];
}
else{
if(a[i]==':'){
if(i+2<a.size()){
if(a[i+1]=='/' && a[i+2]=='/') i+=2;
}
}
else if(a[i]=='/'){
page+='/';
found=true;
}
else{}
}
}
if(page=="") return "/";
return page;
}
/* given: html source code */
/* returns: formatted text webpage */
string get_formated_web(string unformated){
return unformated;
}
<html>
<body>
<p>hola</p>
</body>
</html>
hola
g++ http.cpp -lboost_system
v=num;
v[i]=num;
//Secuencial - OrdenacionSectp5.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
/*Declaración de variables globales*/
unsigned long int MAX=100000;
/*Generar datos*/
void CagarDatos(unsigned long int v[], unsigned long int N)
{
unsigned long int i,j;
int duplicado;
unsigned long int num;
for(i=0; i<N; i++)
{
num=1+rand()%N;
duplicado=0;
for(j=0; j<=i; j++)
{
if(num==v[j])
{
duplicado=1;
break;
}
}
if(duplicado==1)
i--;
else
v[i]=num;
}
}
/*Ordenar Datos de menor a mayor mediante método burbuja*/
void OrdenarDatos(unsigned long int v[], unsigned long int N)
{
unsigned long int i,j;
unsigned long int buffer;
for(i=0; i<N-1; i++)
{
for(j=i+1; j<N; j++)
{
if(v[i]>v[j])
{
buffer=v[j];
v[j]=v[i];
v[i]=buffer;
}
}
}
}
/*Muestra los datos cargados*/
void MostrarDatos(unsigned long int v[], unsigned long int N)
{
unsigned long int i;
printf("\n============================================");
printf("\nNúmeros cargados:\n ");
for(i=0; i<N; i++)
printf("-%ld", v);
}
/*Principal*/
int main()
{
unsigned long int ordenar[MAX];
time_t inicio, fin;
srand(time(NULL));
CagarDatos(ordenar, MAX);
inicio=time(NULL);
OrdenarDatos(ordenar, MAX);
MostrarDatos(ordenar, MAX);
/*Finalización*/
printf("\n============================================");
printf("\nLa cantidad de datos ordenados es: %ld", MAX);
fin=time(NULL);
printf("\nEl programa ha tardado: %.f segundos", difftime(fin,inicio));
printf("\n=========================================\n\n");
return 0;
}
============================================
La cantidad de datos ordenados es: 100000
El programa ha tardado: 142 segundos
=========================================
#include<iostream>
#include<fstream>
using namespace std;
int main(){
ofstream outputfile;
outputfile.open("file1",ios::out);
ifstream readfile;
readfile.open("file2",ios::in);
while(readfile.good()){
char writebuffer=readfile.get();
if(readfile.good())outputfile.put(writebuffer);
}
readfile.close();
outputfile.close();
}
#include<iostream>
#include<fstream>
using namespace std;
int main(){
ofstream outputfile;
outputfile.open("file1",ios::out);
ifstream readfile;
readfile.open("file2",ios::in);
char writebuffer;
while(readfile.read(&writebuffer,1)){
if(readfile.good())outputfile.write(&writebuffer,1);
}
readfile.close();
outputfile.close();
}
while(readfile.good()){
char writebuffer=readfile.get();
if(readfile.good())outputfile.put(writebuffer);
}
readfile.close();
outputfile.close();
retorno=FileToAnalize.tellg()-startpoint;