using System;
class Pruebaparams
{
static int Suma(params int[] operandos)
{
int suma = 0;
for (int i = 0; i < operandos.Length; i++)
{
suma += operandos[i]; // acumulador de los operandos
}
return suma;
}
static void Main()
{
int total = Suma(1, 2, 3, 4, 5);
Console.WriteLine(total); // 15
total = Suma(11, 19, 29);
Console.WriteLine(total); // 59
}
}
dXNpbmcgU3lzdGVtOwoKY2xhc3MgUHJ1ZWJhcGFyYW1zCnsKICAgIHN0YXRpYyBpbnQgU3VtYShwYXJhbXMgaW50W10gb3BlcmFuZG9zKQogICAgewogICAgICAgIGludCBzdW1hID0gMDsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG9wZXJhbmRvcy5MZW5ndGg7IGkrKykKICAgICAgICB7CiAgICAgICAgICAgIHN1bWEgKz0gb3BlcmFuZG9zW2ldOyAgICAgICAgICAgICAgICAgICAvLyBhY3VtdWxhZG9yIGRlIGxvcyBvcGVyYW5kb3MKICAgICAgICB9CgogICAgICAgIHJldHVybiBzdW1hOwogICAgfQoKICAgIHN0YXRpYyB2b2lkIE1haW4oKQogICAgewogICAgICAgIGludCB0b3RhbCA9IFN1bWEoMSwgMiwgMywgNCwgNSk7CiAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUodG90YWwpOyAgICAgICAvLyAxNQogICAgICAgIHRvdGFsID0gU3VtYSgxMSwgMTksIDI5KTsKICAgICAgICBDb25zb2xlLldyaXRlTGluZSh0b3RhbCk7ICAgICAgIC8vIDU5CiAgICB9Cn0=