c#/복습 공부
Method - 반환값x 매개변수o, (for문 사용)
이지훈26
2021. 8. 24. 01:54
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Helloworld
{
class Program
{
static void Main(string[] args)
{
//어떤 음식을 드시겠습니까? : 초밥
//몇번 드시겠습니까? : 3
//초밥을 먹었습니다.
//초밥을 먹었습니다.
//초밥을 먹었습니다.
Console.Write("어떤 음식을 드시겠습니까? :");
string name = Console.ReadLine();
Console.Write("몇번 드시겠습니까? :");
int num = Convert.ToInt32(Console.ReadLine());
EatingFood("초밥", 3);
}
static void EatingFood(string name, int num)
{
for(int i = 0; i<num; i++)
{
Console.WriteLine("{0}을 먹었습니다.", name, num);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Helloworld
{
class Program
{
static void Main(string[] args)
{
//미네랄을 캐는 캐릭터는 뭔가요? : SCV
//몇개를 캤습니까? : 8
//미네랄을 캤습니다.
//미네랄을 캤습니다.
//미네랄을 캤습니다.
//미네랄을 캤습니다.
//미네랄을 캤습니다.
//미네랄을 캤습니다.
//미네랄을 캤습니다.
//미네랄을 캤습니다.
Console.Write("미네랄을 캐는 캐릭터는 뭔가요? :");
string name = Console.ReadLine();
Console.Write("몇개를 캤습니까? :");
int mineral = Convert.ToInt32(Console.ReadLine());
HarvestingCharacter("SCV", 8);
}
static void HarvestingCharacter(string name, int mineral)
{
for(int i = 0; i<mineral; i++)
{
Console.WriteLine("{0}을 캤습니다.", name, mineral);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Helloworld
{
class Program
{
static void Main(string[] args)
{
//생성할 캐릭터는 무엇인가요? : 돼지
//몇개를 생성할까요? : 5
//돼지를 생성했습니다.
//돼지를 생성했습니다.
//돼지를 생성했습니다.
//돼지를 생성했습니다.
//돼지를 생성했습니다.
Console.Write("생성할 캐릭터는 무엇인가요? :");
string name = Console.ReadLine();
Console.Write("몇개를 생성할까요? :");
int mineral = Convert.ToInt32(Console.ReadLine());
ProduceCharacter("돼자", 5);
}
static void ProduceCharacter(string name, intehowl Pig)
{
for(int i = 0; i< Pig; i++)
{
Console.WriteLine("{0}를 생성했습니다.", name, Pig);
}
}
}
}