



Sugestão de resposta do algoritmo em linguagem algorítmica:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | programa AlgoritmoSequencial0008; var X, Y, vAux : Integer; inicio escreva('Informe o valor de X.'); leia(X); escreva('Informe o valor de Y.'); leia(Y); vAux := X; X := Y; Y := vAux; escreva('O valor de X é: ', (X)); escreva('O valor de Y é: ', (Y)); fim. |
Sugestão de resposta em Pascal / Delphi Console.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | { Para escrever acentos em pascal, devemos usar a tabela ASCII. } program Prj00008AlgoritmosSequencias; {$APPTYPE CONSOLE} uses SysUtils, Windows; var X, Y, vAux : Integer; begin SetConsoleTitle('Algoritmo 00008 - Algoritmos sequenciais. Show Delphi.'); Writeln('Algoritmo 00008 - Algoritmos sequenciais. Show Delphi.'); Write(#10#13 + 'Informe o valor de "X": '); Readln(X); Write(#10#13 + 'Informe o valor de "Y": '); Readln(Y); vAux := X; X := Y; Y := vAux; Writeln(#10#13'O valor de "X" '#130': ', X); Writeln('O valor de "X" '#130': ', Y); Write(#10#13#10#13, 'Tecle "Entrer" para sair.'); Readln; end. |
Sugestão de resposta em C, C++ / C Builder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <vcl.h> #pragma hdrstop #include <tchar.h> #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <time.h> #include <string.h> //--------------------------------------------------------------------------- #pragma argsused void _tmain(){ SetConsoleTitleA("Algoritmo 00008 - Algoritmos sequenciais. Show Delphi."); printf("Algoritmo 00008 - Algoritmos sequenciais. Show Delphi.\n"); system("chcp 1252 > nul"); printf("\nInforme o valor de 'X': "); int X; scanf("%d", &X); printf("\nInforme o valor de 'Y': "); int Y; scanf("%d", &Y); int vAux = X; X = Y; Y = vAux; printf("\n O valor de 'X' é: %d ", X); printf("\n O valor de 'Y' é: %d ", Y); printf("\n\n"); system("pause"); } |
Sugestão de resposta em Java com NetBeans
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | package exercicio10; import javax.swing.JOptionPane; /** * * @author Franciele Benedetti */ public class Exercicio10 { /** * @param args the command line arguments */ public static void main(String[] args) { int x = 0; int y = 0; int troca; System.out.println("Informe o primeiro valor "); x = Integer.parseInt(JOptionPane.showInputDialog("Informe o primeiro valor")); System.out.println("Informe o segundo valor "); y = Integer.parseInt(JOptionPane.showInputDialog("Informe o segundo valor")); troca = x; x = y; y = troca; System.out.println("O valor de x é: " + x); System.out.println("O valor de y é: " + y); } } |
Envie também a sua sugestão de algoritmo para [email protected].