0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

cscの作法 その489

Last updated at Posted at 2024-04-13

概要

cscの作法、調べてみた。
練習問題やってみた。

練習問題

sin表を、エクセル出力せよ。

写真

image.png

サンプルコード


using System;
using System.IO;
using ClosedXML.Excel;

namespace App
{
	class Program {
		static void Main(string[] args) {
			var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Book2.xlsx");
			var wb = new XLWorkbook();
			var ws = wb.Worksheets.Add("Sheet1");
			int i;
			int j = 1;
			ws.Cell(j, 1).Value = "角度";
			ws.Cell(j, 2).Value = "SIN";
			ws.Cell(j, 3).Value = "COS";
			for (i = 0; i < 361; i = i + 30)
			{
				double sin = Math.Sin(i * (Math.PI / 180));
				double cos = Math.Cos(i * (Math.PI / 180));
				j++;
				ws.Cell(j, 1).Value = string.Format("{0}°", i);
				ws.Cell(j, 2).Value = string.Format("{0:F3}", sin);
				ws.Cell(j, 3).Value = string.Format("{0:F3}", cos);
			}
			wb.SaveAs(filePath);
			Console.WriteLine("ok");
		}
	}
}



以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?