using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study02
{
internal class Program
{
static void Main(string[] args)
{
Console.Write("몬스터의 체력 : ");
int maxHp = Convert.ToInt32(Console.ReadLine());
int hp = maxHp;
Console.Write("영웅의 공격력 : ");
int att = Convert.ToInt32(Console.ReadLine());
for (; ; )
{
Console.WriteLine("몇 회 공격 하시겠습니까? : ");
int count = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < count; i++)
{
hp -= att;
if(hp <= 0)
{
break;
}
Console.WriteLine("몬스터가 피해({0})를 받았습니다. ({1}/{2})", att, hp, maxHp);
}
if (hp <= 0)
{
Console.WriteLine("몬스터가 피해({0})를 받았습니다. ({1}/{2})", att, 0, maxHp);
Console.WriteLine("몬스터가 죽었습니다.");
break;
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study02
{
internal class Program
{
static void Main(string[] args)
{
for(int i = 0; i < 10; i++)
{
if((i+1)%2 == 0)
{
Console.WriteLine(i+1);
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study02
{
internal class Program
{
static void Main(string[] args)
{
for(int i = 0; i < 4; i++)
{
Console.WriteLine(1000 + i + 1);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study02
{
internal class Program
{
static void Main(string[] args)
{
for(int i = 0; i < 10; i++)
{
if (i % 2 == 1)
{
Console.WriteLine(i);
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study02
{
internal class Program
{
static void Main(string[] args)
{
for(int i = 0; i < 4; i++)
{
Console.WriteLine("{0}교시 {1}:30~",i+1,9+i);
}
for(int i = 0; i < 4; i++)
{
Console.WriteLine("{0}교시 {1}:30~", i + 5, 14 + i);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study02
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("[입력]");
int num = Convert.ToInt32(Console.ReadLine());
int count = 0;
for (int i = 0; i < num-1; i++)
{
count++;
}
Console.WriteLine("[출력]");
if (count == 0)
{
Console.WriteLine("{0}보다 작은 숫자는 없습니다.", num);
}
else
{
Console.WriteLine("{0}보다 작은 숫자는 {1}개입니다.", num, count);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study02
{
internal class Program
{
static void Main(string[] args)
{
for(int i = 0; i < 5; i++)
{
Console.WriteLine(5-i);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study02
{
internal class Program
{
static void Main(string[] args)
{
int sum = 0;
int num;
for(; ; )
{
Console.WriteLine("[입력]");
num = Convert.ToInt32(Console.ReadLine());
if (num <= 10)
{
for(int i = 0; i < num+1; i++)
{
sum += i;
}
break;
}
else
{
Console.WriteLine("잘못 입력했습니다.");
}
}
Console.WriteLine("[출력]");
Console.WriteLine("1부터 {0}까지 합은 {1}입니다.", num, sum);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study02
{
internal class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 5; i++)
{
Console.Write("줄넘기를 총{0}회 했습니다.",(i+1));
if ((i+1) % 2 == 0)
{
Console.Write(" 야호~");
}
Console.WriteLine();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study02
{
enum menu
{
zzazang = 1,
zzambbong = 2,
tangsuyuk = 3
}
internal class Program
{
static void Main(string[] args)
{
int zzazangCount = 0;
int zzambongCount = 0;
int tangCount = 0;
int menu;
int price =0;
Console.WriteLine("홍콩반점에 오신걸 환영합니다.");
Console.Write("소지금액 : ");
int won = Convert.ToInt32(Console.ReadLine());
Console.Write("총 몇분이신가요? : ");
int count = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("[출력]");
Console.WriteLine("{0}명, 소지금액 : {1}", count, won);
Console.WriteLine("[출력]");
Console.WriteLine("-----------------------");
Console.WriteLine("메뉴판");
Console.WriteLine("-----------------------");
Console.WriteLine("1. 짜장면 6000원\n2. 짬뽕 8000원\n3. 탕수육 12000원\n\n");
Console.WriteLine("[출력]");
for(int i = 0; i < count; i++)
{
Console.WriteLine("메뉴를 주문해주세요");
menu = Convert.ToInt32(Console.ReadLine());
if((menu)menu == study02.menu.zzazang)
{
zzazangCount++;
}
else if ((menu)menu == study02.menu.zzambbong)
{
zzambongCount++;
}
else if ((menu)menu == study02.menu.tangsuyuk)
{
tangCount++;
}
else
{
Console.WriteLine("범위 내에서만 주문해주세요");
i--;
}
}
Console.WriteLine("[출력]");
Console.WriteLine("-----------------------");
Console.WriteLine("주문 내역");
Console.WriteLine("-----------------------");
if(zzazangCount > 0)
{
Console.WriteLine("짜장면 {0}개 {1}원", zzazangCount, 6000 * zzazangCount);
price = price + (6000 * zzazangCount);
}
if (zzambongCount > 0)
{
Console.WriteLine("짬뽕 {0}개 {1}원", zzambongCount, 8000 * zzambongCount);
price = price + (8000 * zzazangCount);
}
if (tangCount > 0)
{
Console.WriteLine("짜장면 {0}개 {1}원", tangCount, 12000 * tangCount);
price = price + (12000 * tangCount);
}
Console.WriteLine("-----------------------");
Console.WriteLine("합계 {0}원", price);
if(won < price)
{
Console.WriteLine("[출력]");
Console.WriteLine("{0}원이 부족 합니다\n다음에 다시 오세요~", price - won);
}
else
{
Console.WriteLine("[출력]");
Console.WriteLine("감사합니다.\n현재 남은 소지 금액은 {0}원 입니다\n안녕히 가세요~", won - price);
}
}
}
}