Você está na página 1de 7

Avaliao 10/06/2013

Questo 01

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace Exercicios_01_ProvaSegunda { class Program { static void fetuccini(int anterior, int atual) { int cont = 3, proximo =0; Console.WriteLine(anterior.ToString()); Console.WriteLine(atual.ToString()); for (cont = 3; cont <= 50; cont++) { if (cont % 2 == 0) { proximo = anterior + atual; } else { proximo = atual - anterior; } anterior = atual; atual = proximo; Console.WriteLine(proximo.ToString()); } } static void Main(string[] args) { int atual, anterior; atual = anterior = 0; Console.Write("Informe o primeiro valor da serie ..: "); anterior = int.Parse(Console.ReadLine()); Console.Write("Informe o segundo valor da serie ..: "); atual = int.Parse(Console.ReadLine()); fetuccini(anterior, atual); Console.ReadKey(); } } }

Questo 02
using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace Exercicios_01_ProvaSegunda { class Program { static double serie() { double s = 0, num = 1, ant = 1, prox = 0, den = 0, exp = 1, div = 3, qtsinal = 1, contsinal = 1 ; char sinal = '-';

while (num <= 49) { while (contsinal <= qtsinal && num <= 49) { den = ant + prox; ant = prox; prox = den; while (div > 2) { div = 0; exp++; for (int cont = 1; cont <= exp; cont++) { if (exp % cont == 0) div++; } } div = 3; Console.WriteLine(sinal.ToString() + num.ToString() + " EXP " + exp.ToString() + "/" + den.ToString()); if (sinal == '+') s += Math.Pow(num, exp) / den; else s -= Math.Pow(num, exp) / den; num += 2; contsinal++; } if (sinal == '+') sinal = '-'; else sinal = '+'; contsinal = 1; qtsinal++; }

return s;

} static void Main(string[] args) { double s = 0; s = serie(); Console.WriteLine(s.ToString()); Console.ReadKey(); } } }

Questo 03

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace Exercicios_01_ProvaSegunda { class Program { static int multiplica(int[,] mat) { int l = 0, c = 0; int res = 1; for (l = 0; l < 10; l++) { for (c = 0; c < 10; c++) { if ((l + c) == 9) res *= mat[l, c]; } } return res;

} static void Main(string[] args) { int[,] mat = new int[10, 10]; int l = 0, c = 0; int res = 0; for(l = 0; l<10;l++) { for(c = 0; c<10;c++) { Console.Write("MAT[" + l.ToString() + "," + c.ToString() + "]..:");

mat[l, c] = int.Parse(Console.ReadLine()); } } res = multiplica(mat); Console.WriteLine(res.ToString());

Console.ReadKey(); } } }

Avaliao 12/06/2013

Questo 01
using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace Exercicios_01_ProvaSegunda { class Program { static void fetuccini(int anterior, int atual) { int cont = 3, proximo = 0, somatorio = 0; Console.WriteLine(anterior.ToString()); Console.WriteLine(atual.ToString()); for (cont = 2; cont <= 10; cont++) { if (cont % 2 == 0) { proximo = anterior + atual; } else { proximo = atual - anterior; for (int aux = 1; aux <= proximo; aux++) { somatorio += aux; } proximo = somatorio; somatorio = 0; } anterior = atual; atual = proximo; Console.WriteLine(proximo.ToString());

} } static void Main(string[] args) { int atual, anterior; atual = anterior = 0; Console.Write("Informe o primeiro valor da serie ..: "); anterior = int.Parse(Console.ReadLine()); Console.Write("Informe o segundo valor da serie ..: "); atual = int.Parse(Console.ReadLine()); fetuccini(anterior, atual); Console.ReadKey(); } } }

Questo 02
using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace Exercicios_01_ProvaSegunda { class Program { static double serie() { double s = 0, num = 1, ant = 1, prox = 0, den = 1, exp = 0, div = 3, qtsinal = 1, contsinal = 1; char sinal = '+';

while (num <= 49) { while (contsinal <= qtsinal && num <= 49) { exp = ant + prox; ant = prox; prox = exp; while (div > 2) { div = 0; den++; for (int cont = 1; cont <= den; cont++) { if (den % cont == 0) div++; } } div = 3; Console.WriteLine(sinal.ToString() + num.ToString() + " EXP " + exp.ToString() + "/" + den.ToString());

if (sinal == '+') s += Math.Pow(num, exp) / den; else s -= Math.Pow(num, exp) / den; num += 2; contsinal++; } if (sinal == '+') sinal = '-'; else sinal = '+'; contsinal = 1; qtsinal++; }

return s;

} static void Main(string[] args) { double s = 0; s = serie(); Console.WriteLine(s.ToString()); Console.ReadKey(); } } }

Questo 03
using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace Exercicios_01_ProvaSegunda { class Program { static int perfeito(int[,] mat) { int l = 0, c = 0; int res = 1, somatorio = 0, qtde = 0 ; for (l = 0; l < 10; l++) { for (c = 0; c < 10; c++) { if ((l + c) == 9) {

res = mat[l, c] + mat[l, l]; somatorio = 0; for (int cont = 1; cont < res; cont++) { if (res % cont == 0) somatorio += cont; } if (somatorio == res && res != 0) qtde++; }

} } return qtde;

} static void Main(string[] args) { int[,] mat = new int[10, 10]; int l = 0, c = 0; int res = 0;

for (l = 0; l < 10; l++) { for (c = 0; c < 10; c++) { Console.Write("MAT[" + l.ToString() + "," + c.ToString() + "]..:"); mat[l, c] = int.Parse(Console.ReadLine()); } } res = perfeito(mat); Console.WriteLine(res.ToString());

Console.ReadKey(); } } }

Você também pode gostar