-
Posts
93 -
Cadastrado em
-
Última visita
Tipo de conteúdo
Artigos
Selos
Fabricantes
Livros
Cursos
Análises
Fórum
Tudo que Nayuugga postou
-
C Função que aceita todos os diferentes tipos de dados como parâmetro
Nayuugga respondeu ao tópico de Lucas Da Silva Rezende em C/C#/C++
Há algumas maneiras de se fazer isso: Você pode usar void* como parâmetro: struct lista { Lista* Proxima; void* Valor; }; Lista* inserir(void* valor) { //Código de inserção } Ou usar Templates. Exemplos: http://www.cplusplus.com/doc/oldtutorial/templates/ -
#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; }
-
Você quer que mostre conforme digita ou dado uma string mostrar na tela devagar letra por letra?
-
i<j não i <=j
-
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);
-
O comando system("color XX") muda o cor do console e não de uma string específica. Tente dar uma estudada na biblioteca graphics.h
-
#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.
-
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; }
-
Ajuda com manipulaçao de arquivos em C++
Nayuugga respondeu ao tópico de LucasAlvesSilva em C/C#/C++
while(fgetc(arquivo) != EOF) contador++; -
if(num_divisores<=2) { if(aux%2) { f = pow(numero,-1); } else { f = pow(-1*numero,-1); } soma += f;//ACRESCENTE ESTA LINHA!! aux++; printf(" %f ",f); }
-
Mostre o que você já fez até agora para que possamos ajudar!!!
-
Foi só uma maneira de se fazer diferente. Ele usa uma estrutura para representar o nó da pilha e a outra para ser a própria pilha. Eu usaria uma única struct neste caso.
-
Como identificar o numero de espaços em um vetor?
Nayuugga respondeu ao tópico de LucasAlvesSilva em C/C#/C++
Pelo que seu professor quis dizer ele disse que os números no vetor pode se repetir mesmo estando em ordem crescente. Ex: 1, 2, 2, 5, 6, 6, 8, 50, 63, 63, 70 Quanto ao cin: int vetor[n];for (int i = 0; i < n; i++){ cout << "Numero " << (i + 1) << ": "; cin >> vetor[i];} -
char data[] = "23/04/2015 05:16:46"; char data[] = webBrowser1->DocumentText;
-
A variável tamInfo não é o dado. Ele é o tamanho em bytes da váriavel dados. A segunda linha do if aloca essa variável com o tamanho passado.
-
É por causa dos delays chamados dentro dos métodos de efeitos. O botão demora cerca de 1 segundo para mudar..
-
Sim você está certo! Porém recomendo que utilize linguagens de alto nível para criar WindowsForms como c#! Abraços
-
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);}
-
Tente assim então: unsigned char flag = 0;unsigned char ap = 0;void main(){ do { if (input(mode) && !ap) { flag = !flag; ap = 1; } if (!input(mode) && ap) ap = 0; if (flag) efeito1(); else efeito2(); } while (true);}
-
Tente assim: // programa principalvoid main(){ do { if (input(mode)) efeito1(); else efeito2(); } while (true);}
-
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.
-
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!
-
Seu programa nunca esta saindo do laço for. A condição : if (acum == expp) {break;} nunca está sendo satisfeita.
-
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