Ir ao conteúdo
  • Cadastre-se

Nayuugga

Membro Pleno
  • Posts

    93
  • Cadastrado em

  • Última visita

posts postados por Nayuugga

  1. 
    

    #include <stdio.h>

    #include <stdlib.h>

    int main()

    {

    int valor = 0;

    int unidade = 0;

    int dezena = 0;

    int centena = 0;

    printf("Informe o valor: ");

    scanf("%d", &valor);

    unidade = valor % 10;

    dezena = (valor / 10) % 10;

    centena = (valor / 100) % 10;

    if (centena % 2 == 0)

    printf("PAR\n");

    else

    printf("IMPAR\n");

    system("PAUSE");

    return 0;

    }

  2. 
    

    using System;

    using System.Collections.Generic;

    using System.Drawing;

    using System.Drawing.Imaging;

    using System.Drawing.Printing;

    using System.IO;

    using System.Linq;

    using System.Text;

    using System.Windows.Forms;

    using DevExpress.XtraEditors;

    using Microsoft.Reporting.WinForms;

    //....

    public static void Imprimir(LocalReport report,string nomeImpressora)

    {

    string deviceInfo =

    "<DeviceInfo>" +

    " <OutputFormat>EMF</OutputFormat>" +

    " <PageWidth>210mm</PageWidth>" +

    " <PageHeight>297mm</PageHeight>" +

    " <MarginTop>0mm</MarginTop>" +

    " <MarginLeft>0mm</MarginLeft>" +

    " <MarginRight>0mm</MarginRight>" +

    " <MarginBottom>0mm</MarginBottom>" +

    "</DeviceInfo>";

    Warning[] warnings;

    report.Render("Image", deviceInfo, CreateStream, out warnings);

    foreach (Stream stream in m_streams)

    stream.Position = 0;

    Print(nomeImpressora);

    if (m_streams != null)

    {

    foreach (Stream stream in m_streams)

    stream.Close();

    m_streams = null;

    }

    }

    
    

    PrintDialog tela = new PrintDialog();

    string nomeImpressora = "";

    if (tela.ShowDialog() != DialogResult.OK)

    return;

    nomeImpressora = tela.PrinterSettings.PrinterName;

    LocalReport relatorio = new LocalReport();

    relatorio.ReportEmbeddedResource = "relatorio.rdlc";

    Imprimir(relatorio, nomeImpressora);

    
    

  3. #include<iostream>int main(){    int i=0,num[10],menor =0,n =1;    while(n != 0){         std::cin>>num[i];//   if (i == 0)//      menor = num[i];//Esse código deve ser inserido.                if(num[i] == 0){            n =0;        }        if(num[i] < menor){//Deveria ser else if aqui            num[i] = menor; //Deveria ser (menor = num[i] aqui.        }        i +=1;    }        std::cout<<menor;}.

    Sua lógica contém alguns erros, mas é uma boa lógica. Tente refazê-la de novo ou use a solução apresentada pela Isis Binder.

  4. 
    

    int* EliminarRepetidos(int* vetor, int tamanhoVetor, int* novoTamanhoVetor)

    {

    int* novoVetor = NULL;

    int id = -1;

    for (int i = tamanhoVetor; i >= 0; i--)

    {

    for (int j = i - 1; j >= 0; j--)

    {

    if (vetor == vetor[j])

    {

    for (int w = i + 1; w < tamanhoVetor; w++)

    vetor = vetor[w];

    tamanhoVetor--;

    }

    }

    }

    novoVetor = (int*)malloc(sizeof(int) * tamanhoVetor);

    for (int i = 0; i < tamanhoVetor; i++)

    novoVetor = vetor;

    *novoTamanhoVetor = tamanhoVetor;

    return novoVetor;

    }

  5. Pra 3 tem que ser assim:

    unsigned char flag = 0;unsigned char ap = 0;void main(){   unsigned char quantidadeEfeitos = 3;//Mude a quantidade de efeitos aqui..   do   {      if (input(mode) && !ap)      {         flag++;         ap = 1;         if (flag >= quantidadeEfeitos)           flag = 0;      }      if (!input(mode) && ap)         ap = 0;            switch (flag)      {          case 0: efeito1(); break;          case 1: efeito2(); break;          case 2: efeito3(); break;          //Insira mais efeitos aqui..      }   }   while (true);}
  6. 	template<class _Iter>		void _BConstruct(_Iter _First, _Iter _Last)		{	// initialize from [_First, _Last), input iterators		insert(begin(), _First, _Last);		}	vector(_Myt&& _Right)		: _Mybase(_STD forward<_Myt>(_Right))		{	// move construct by moving _Right		}	vector(_Myt&& _Right, const _Alloc& _Al)		: _Mybase(_STD forward<_Myt>(_Right), _Al)		{	// move construct by moving _Right, allocator		}	_Myt& operator=(_Myt&& _Right)		{	// assign by moving _Right		if (this != &_Right)			{	// different, assign it			clear();			if (_Alty::propagate_on_container_move_assignment::value				&& this->get_allocator() != _Right.get_allocator())				{	// assign vector, dumping proxy				this->_Free_proxy();				this->_Myvec = _STD move(_Right._Myvec);				this->_Alloc_proxy();				}			else				this->_Myvec = _STD move(_Right._Myvec);			this->_Mysize = _Right._Mysize;			_Right._Mysize = 0;			}		return (*this);		}	vector(_XSTD initializer_list<bool> _Ilist,			const _Alloc& _Al = allocator_type())		: _Mybase(0, false, _Al)		{	// construct from initializer_list		insert(begin(), _Ilist.begin(), _Ilist.end());		}	_Myt& operator=(_XSTD initializer_list<bool> _Ilist)		{	// assign initializer_list		assign(_Ilist.begin(), _Ilist.end());		return (*this);		}	void assign(_XSTD initializer_list<bool> _Ilist)		{	// assign initializer_list		assign(_Ilist.begin(), _Ilist.end());		}	iterator insert(const_iterator _Where,			_XSTD initializer_list<bool> _Ilist)		{	// insert initializer_list		return (insert(_Where, _Ilist.begin(), _Ilist.end()));		}	~vector() _NOEXCEPT		{	// destroy the object		this->_Mysize = 0;		}	_Myt& operator=(const _Myt& _Right)		{	// assign from _Right		this->_Mysize = _Right._Mysize;		this->_Myvec = _Right._Myvec;		return (*this);		}	void reserve(size_type _Count)		{	// determine new minimum length of allocated storage		this->_Myvec.reserve(this->_Nw(_Count));		}	size_type capacity() const _NOEXCEPT		{	// return current length of allocated storage		return (this->_Myvec.capacity() * _VBITS);		}	iterator begin() _NOEXCEPT		{	// return iterator for beginning of mutable sequence		return (iterator((_Vbase *)this->_Myvec._Myfirst, this));		}	const_iterator begin() const _NOEXCEPT		{	// return iterator for beginning of nonmutable sequence		return (const_iterator((_Vbase *)this->_Myvec._Myfirst, this));		}	iterator end() _NOEXCEPT		{	// return iterator for end of mutable sequence		iterator _Tmp = begin();		if (0 < this->_Mysize)			_Tmp += this->_Mysize;		return (_Tmp);		}	const_iterator end() const _NOEXCEPT		{	// return iterator for end of nonmutable sequence		const_iterator _Tmp = begin();		if (0 < this->_Mysize)			_Tmp += this->_Mysize;		return (_Tmp);		}	const_iterator cbegin() const _NOEXCEPT		{	// return iterator for beginning of nonmutable sequence		return (((const _Myt *)this)->begin());		}	const_iterator cend() const _NOEXCEPT		{	// return iterator for end of nonmutable sequence		return (((const _Myt *)this)->end());		}	const_reverse_iterator crbegin() const _NOEXCEPT		{	// return iterator for beginning of reversed nonmutable sequence		return (((const _Myt *)this)->rbegin());		}	const_reverse_iterator crend() const _NOEXCEPT		{	// return iterator for end of reversed nonmutable sequence		return (((const _Myt *)this)->rend());		}	void shrink_to_fit()		{	// reduce capacity		if (this->_Myvec._Has_unused_capacity())			{	// worth shrinking, do it			_Myt _Tmp(*this);			swap(_Tmp);			}		}	iterator _Make_iter(const_iterator _Where)		{	// make iterator from const_iterator		iterator _Tmp = begin();		if (0 < this->_Mysize)			_Tmp += _Where - begin();		return (_Tmp);		}	reverse_iterator rbegin() _NOEXCEPT		{	// return iterator for beginning of reversed mutable sequence		return (reverse_iterator(end()));		}	const_reverse_iterator rbegin() const _NOEXCEPT		{	// return iterator for beginning of reversed nonmutable sequence		return (const_reverse_iterator(end()));		}	reverse_iterator rend() _NOEXCEPT		{	// return iterator for end of reversed mutable sequence		return (reverse_iterator(begin()));		}	const_reverse_iterator rend() const _NOEXCEPT		{	// return iterator for end of reversed nonmutable sequence		return (const_reverse_iterator(begin()));		}	void resize(size_type _Newsize, bool _Val = false)		{	// determine new length, padding with _Val elements as needed		if (size() < _Newsize)			_Insert_n(end(), _Newsize - size(), _Val);		else if (_Newsize < size())			erase(begin() + _Newsize, end());		}	size_type size() const _NOEXCEPT		{	// return length of sequence		return (this->_Mysize);		}

    se abrir o cabeçário vector.h verá o seguinte trecho de código acima, o último método - size() é declarado e implementado dentro da classe _Iter classe base da classe vector e list,

    sendo portanto inline. Isso prova que não perde performance pois o método é reescrito no local de chamado sendo inline.

  7. int DesempilharInversamente(Item **topo){   Item* it = NULL;   Item* auxiliar = NULL;   int result = -1;   for (it = (*topo); it->proximo != NULL; it = it->proximo)        if (it->proximo->proximo == NULL)            break;   auxiliar = it->proximo;   if (auxiliar)   {      result = it->proximo->numero;      it->proximo = NULL;      free(auxiliar);   }   else   {      result = it->numero;      free(it);      *topo = NULL;//Essa linha aqui!!!   }   return result;}

    testei este código e deu certo agora!

  8. 
    

    int DesempilharInversamente(Item **topo)

    {

    Item* it = NULL;

    Item* auxiliar = NULL;

    int result = -1;

    for (it = (*topo); it->proximo != NULL; it = it->proximo)

    if (it->proximo->proximo == NULL)

    break;

    auxiliar = it->proximo;

    if (auxiliar)

    {

    result = it->proximo->numero;

    it->proximo = NULL;

    free(auxiliar);

    }

    else

    {

    result = it->numero;

    free(it);

    *topo = NULL;//INSIRA ESTE CÓDIGO E TESTE AGORA

    }

    return result;

    }

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...