티스토리 뷰
C# 한줄에 두수 입력하여 합구하기
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CsReadWrite
{
class Program
{
static void Main(string[] args)
{
int N = 2;
int i, j, num, sum;
string str;
Console.WriteLine("한줄에 두개의 정수 입력하세요");
int intch;
char ch;
int[] elem = new int[N];
for (i = 0, sum = 0; i < 2; i++)
{
intch = Console.Read();
ch = Convert.ToChar(intch);
num = 0;
while (ch != ' ' && ch != '\r')
{
num = num * 10 + (intch - 48);
intch = Console.Read();
ch = Convert.ToChar(intch);
};
elem[i] = num;
Console.WriteLine(" {0} ", elem[i]);
sum += num;
}
Console.WriteLine(sum);
}
}
}
'It' 카테고리의 다른 글
스프링 컨테이너 2-2결합도와 유지보수성 (0) | 2022.10.24 |
---|---|
오라클 SQL함수 (0) | 2022.10.22 |
JSP (DB값 검색 / DB값 수정/ DB값 불러오기) (12/3) 해당하는 코드정보 불러오기 (0) | 2022.10.18 |
오라클 , MS-SQL , MY-SQL (0) | 2022.10.10 |
코드의종류 7가지 (0) | 2022.10.09 |
댓글