my code stock.com

asdasdas

Snippet options

Download: Download snippet as practica1-poo.cpp.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

#include <iostream>
#include <algorithm>
#include <string>

using namespace::std;

void registro();
void minusculas();
void mayusculas();
void primeraMayuscula();

struct data{
	string nombre;
	string apellido;
	
};

data contactos[3];

void main()
{
	registro();

	minusculas();

	for(int i=0; i<3; i++)
	{
	cout<<endl<<contactos[i].nombre<<" "<<contactos[i].apellido<<endl;
	}
	

	mayusculas();

	for(int i=0; i<3; i++)
	{
	cout<<endl<<contactos[i].nombre<<" "<<contactos[i].apellido<<endl;
	}

	primeraMayuscula();
	for(int i=0; i<3; i++)
	{
	cout<<endl<<contactos[i].nombre<<" "<<contactos[i].apellido<<endl;
	}
	system("pause");
}

void registro()
{
	for(int i=0; i<3; i++)
	{
		cout<<endl;
		cout<<"Ingrese nombre."<< endl;
		cin>>contactos[i].nombre;
		cout<<"Ingrese apellido."<< endl;
		cin>>contactos[i].apellido;
	}
}
void minusculas()
{
	for(int i=0; i<3; i++)
	{
		std::transform(contactos[i].nombre.begin(), contactos[i].nombre.end(), contactos[i].nombre.begin(), ::tolower);
		std::transform(contactos[i].apellido.begin(), contactos[i].apellido.end(), contactos[i].apellido.begin(), ::tolower);
	}

}

void mayusculas()
{
	for(int i=0; i<3; i++)
	{
		std::transform(contactos[i].nombre.begin(), contactos[i].nombre.end(), contactos[i].nombre.begin(), ::toupper);
		std::transform(contactos[i].apellido.begin(), contactos[i].apellido.end(), contactos[i].apellido.begin(), ::toupper);
	}

}

void primeraMayuscula()
{
	string str;
	string str2;

	
	for(int i=0; i<3; i++)
	{
		
		str=contactos[i].nombre[0];
		str2=contactos[i].apellido[0];

		std::transform(contactos[i].nombre.begin(), contactos[i].nombre.end(), contactos[i].nombre.begin(), ::tolower);
		std::transform(contactos[i].apellido.begin(), contactos[i].apellido.end(), contactos[i].apellido.begin(), ::tolower);

		std::transform(str.begin(), str.end(), str.begin(), ::toupper);
		std::transform(str2.begin(), str2.end(), str2.begin(), ::toupper);

		contactos[i].nombre.front()=str[0];
		contactos[i].apellido.front()=str2[0];
	}

}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.