+ 2
Cómo se puede sumar los puntos y nombres de bailarines que te da la máquina?
Ejercicio 57 de C#
3 Antworten
+ 2
Espero que mi código te sirva
using System;
using System.Collections.Generic;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
string name1 = Console.ReadLine();
int points1 = Convert.ToInt32(Console.ReadLine());
string name2 = Console.ReadLine();
int points2 = Convert.ToInt32(Console.ReadLine());
DancerPoints dancer1 = new DancerPoints(name1, points1);
DancerPoints dancer2 = new DancerPoints(name2, points2);
DancerPoints total = dancer1 + dancer2;
Console.WriteLine(total.name);
Console.WriteLine(total.points);
}
}
class DancerPoints
{
public string name;
public int points;
public DancerPoints(string name, int points)
{
this.name = name;
this.points = points;
}
//sobrecarga el operador +
public static Dancer
0
Hola tengo este código.
using System;
using System.Collections.Generic;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int levels = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(Points(levels));
}
static int Points(int levels)
{
//your code goes here
int total = (levels + 1) * levels / 2;
return total;
}
}
}
0
Gracias por responder.