Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
AnswerRe: simple log in authorized member sample! Pin
Tim Carmichael16-May-14 2:35
Tim Carmichael16-May-14 2:35 
GeneralRe: simple log in authorized member sample! Pin
Hakan Bulut16-May-14 2:56
Hakan Bulut16-May-14 2:56 
QuestionASP.Net Development Server Pin
Member 1082292915-May-14 23:33
Member 1082292915-May-14 23:33 
SuggestionRe: ASP.Net Development Server Pin
Richard MacCutchan16-May-14 0:48
mveRichard MacCutchan16-May-14 0:48 
QuestionRead and write the xml file which does not have proper stylishing Pin
Rajiv2206415-May-14 22:06
Rajiv2206415-May-14 22:06 
AnswerRe: Read and write the xml file which does not have proper stylishing Pin
Mycroft Holmes15-May-14 22:34
professionalMycroft Holmes15-May-14 22:34 
SuggestionRe: Read and write the xml file which does not have proper stylishing Pin
V.15-May-14 23:03
professionalV.15-May-14 23:03 
QuestionChange stack code to queue code. Pin
Alexandrino Neto15-May-14 15:51
Alexandrino Neto15-May-14 15:51 
Friends, i need a code to make the function queue, deletions at the beginning and at the end inclisões. This code works correctly as Stack. I need it to work as a queue. Please Smile | :)

C#
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
 
public class Pilha 
{ 
   private int[] valores; 
   private int topo; 
 
   public Pilha(int n) /* Método construtor */ 
   { 
       if (n > 0) 
       { 
           valores = new int[n]; 
           topo = -1; 
       } 
   } 
 
   public int Push(int valor)   /* Método para empilhar */ 
   { 
       if (topo < valores.Length - 1) 
       { 
           topo++; 
           valores[topo] = valor; 
           return 0; 
       } 
       return -1; 
   } 
 
   public int Pop() /* Método para desempilhar */ 
   { 
       if (topo >= 0) 
       { 
           int valor = valores[topo]; 
           topo--; 
           return valor; 
       } 
       else return -1;  /* Stack Underflow */ 
   } 
 
   public string ImprimirPilha()    /* Método para imprimir a pilha */ 
   { 
       string saida = "\t"; 
       if (topo >= 0) 
       { 
           for (int i = topo; i >= 0; i--) 
           { 
               saida = saida + valores[i] + "\n\t"; 
           } 
           return saida; 
       } 
       else return "\tPilha Vazia"; 
   } 
} 
 
namespace ConsoleApplication1 
{ 
   class Program 
   { 
       static void Main(string[] args) 
       { 
           Pilha pilha = new Pilha(5); 
           int sair = 0; 
           string imprime = ""; 
           while (sair == 0) 
           { 
               imprimeOpcoes(); 
               int opcao = int.Parse(Console.ReadLine()); 
               if (opcao == 0) 
               { 
                   sair = 1; 
               } 
               else 
                   if (opcao == 1) 
                   { 
                       Console.Clear(); 
                       Console.WriteLine("Digite um numero para inserir na pilha\n"); 
                       pilha.Push(int.Parse(Console.ReadLine())); 
                       imprime = pilha.ImprimirPilha(); 
                       Console.WriteLine(imprime); 
                   } 
                   else 
                       if (opcao == 2) 
                       { 
                           Console.Clear(); 
                           pilha.Pop(); 
                           imprime = pilha.ImprimirPilha(); 
                           Console.WriteLine(imprime); 
                       } 
                       else 
                           if (opcao == 3) 
                           { 
                               Console.Clear(); 
                               imprime = pilha.ImprimirPilha(); 
                               Console.WriteLine(imprime); 
                           } 
           } 
       } 
       static public void imprimeOpcoes() 
       { 
           Console.WriteLine("\nEscolha uma opção:\n"); 
           Console.WriteLine("Sair digite 0"); 
           Console.WriteLine("Inserir na pilha digite 1"); 
           Console.WriteLine("Tirar da pilha digite 2"); 
           Console.WriteLine("Imprimir pilha digite 3\n"); 
       } 
   } 
}

AnswerRe: Change stack code to queue code. Pin
Richard Andrew x6415-May-14 17:33
professionalRichard Andrew x6415-May-14 17:33 
AnswerRe: Change stack code to queue code. Pin
Dave Kreskowiak15-May-14 18:34
mveDave Kreskowiak15-May-14 18:34 
GeneralRe: Change stack code to queue code. Pin
OriginalGriff15-May-14 21:43
mveOriginalGriff15-May-14 21:43 
GeneralRe: Change stack code to queue code. Pin
Dave Kreskowiak16-May-14 1:53
mveDave Kreskowiak16-May-14 1:53 
QuestionListening to system Event Log and detect specific events Pin
Ayoub SâaDii15-May-14 5:09
Ayoub SâaDii15-May-14 5:09 
AnswerRe: Listening to system Event Log and detect specific events Pin
Richard Andrew x6415-May-14 5:11
professionalRichard Andrew x6415-May-14 5:11 
GeneralRe: Listening to system Event Log and detect specific events Pin
Ayoub SâaDii15-May-14 5:15
Ayoub SâaDii15-May-14 5:15 
AnswerRe: Listening to system Event Log and detect specific events Pin
BillWoodruff15-May-14 13:42
professionalBillWoodruff15-May-14 13:42 
QuestionCustom Listbox' scrollbar painting Pin
op7515-May-14 3:06
op7515-May-14 3:06 
AnswerRe: Custom Listbox' scrollbar painting Pin
Ravi Bhavnani15-May-14 4:26
professionalRavi Bhavnani15-May-14 4:26 
GeneralRe: Custom Listbox' scrollbar painting Pin
op7515-May-14 21:44
op7515-May-14 21:44 
QuestionHow to get position a Child Window & its items? Pin
Member 1063699815-May-14 2:06
Member 1063699815-May-14 2:06 
AnswerRe: How to get position a Child Window & its items? Pin
Eddy Vluggen15-May-14 2:58
professionalEddy Vluggen15-May-14 2:58 
GeneralRe: How to get position a Child Window & its items? Pin
Member 1063699815-May-14 4:16
Member 1063699815-May-14 4:16 
GeneralRe: How to get position a Child Window & its items? Pin
Member 1063699815-May-14 5:31
Member 1063699815-May-14 5:31 
GeneralRe: How to get position a Child Window & its items? Pin
Member 1063699815-May-14 7:16
Member 1063699815-May-14 7:16 
GeneralRe: How to get position a Child Window & its items? Pin
Eddy Vluggen15-May-14 7:49
professionalEddy Vluggen15-May-14 7:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.