-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB01.cs
More file actions
56 lines (47 loc) · 1.66 KB
/
B01.cs
File metadata and controls
56 lines (47 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// 正方形の面積を計算するプログラム
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B01
{
class Program
{
static void Main(string[] args){
int A = 0;
int B = 0;
int correct_count = 0;
while(true)
{
Console.WriteLine("A、Bとも1以上100以下の整数を入力してください");
try
{
A = int.Parse(Console.ReadLine());
if((A < 1) || (A > 100)){
Console.WriteLine("指定された範囲の数字を入力してください");
} else {
correct_count += 1;
}
B = int.Parse(Console.ReadLine());
if((B < 1) || (B > 100)){
Console.WriteLine("指定された範囲の数字を入力してください");
} else {
correct_count += 1;
}
if (correct_count == 2){
break;
} else {
correct_count = 0;
}
}
catch(FormatException ){
Console.WriteLine("整数以外は入力しないでください");
}
}
double ans;
ans = A + B;
Console.WriteLine(ans);
}
}
}