-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA01.cs
More file actions
35 lines (34 loc) · 1.04 KB
/
A01.cs
File metadata and controls
35 lines (34 loc) · 1.04 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
// 正方形の面積を計算するプログラム
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A01
{
class Program
{
static void Main(string[] args){
int num;
while(true)
{
Console.WriteLine("1以上100以下の整数を入力してください");
try
{
num = int.Parse(Console.ReadLine());
if((num < 1) || (num > 100)){
Console.WriteLine("1以上100以下の整数を入力してください");
} else {
break;
}
}
catch(FormatException ){
Console.WriteLine("整数以外は入力しないでください");
}
}
double S;
S = Math.Pow(num,2);
Console.WriteLine(S);
}
}
}