当前位置:网站首页>2020-11-07
2020-11-07
2020-11-10 10:41:00 【osc_b88oux8w】
运用C#语言
1.求π/2的近似值的公式:
π/2=2/12/34/3*…2n/2n-12n/2n+1,求当n=1000时π的近似值
using System;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
int n;
double pi=1;
for (n = 1; n <= 1000; n++)
{
pi=pi*2*n/(2*n-1)*2*n/(2*n+1);
}
Console.WriteLine("输出近似值: " +2*pi);
}
}
}

2.设计一个程序,输入一个十进制数,输出相应的十六进制数
using System;
namespace jinzhizhuanhuan
{
class Program
{
private static string result;
static void Main(string[] args)
{
Console.WriteLine("请输入十进制数: ");
int m = int.Parse(Console.ReadLine());
String result= Convert.ToString(m, 16);
Console.WriteLine("十六进制数为: " );
Console.WriteLine(m.ToString("X"));
}
}
}

3.找出数组a中最大值的下标,输出下标及最大值
using System;
namespace zuidazhix
{
class Program
{
static void Main(string[] args)
{
int max;
int i;
int j;
int[] her = new int[] {
89, 23, 45, 34, 34, 56, 6, 5, 9, 21 };
max = her[0];
for (i = 1; i < her.Length; i++)
{
if (her[i] > max)
{
max = her[i];
}
}
Console.WriteLine("最大值是: " + max);
for (j = 0; j < her.Length; j++)
{
if (her[j] == max) {
Console.WriteLine("下标是: "+j);
}
}
}
}
}

版权声明
本文为[osc_b88oux8w]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4375893/blog/4710537
边栏推荐
- 【操作教程 】国标GB28181协议安防视频平台EasyGBS订阅功能介绍及开启步骤
- Android quick shutdown app
- leetcode1-两数之和
- [论文阅读笔记] Community-oriented attributed network embedding
- 走进C# abstract,了解抽象类与接口的异同
- [论文阅读笔记] Network Embedding with Attribute Refinement
- Connection to XXX could not be established. Broker may not be available
- Several solutions to the problem that selenium webdriver always fails to use click
- 分布式文档存储数据库之MongoDB索引管理
- [论文阅读笔记] Large-Scale Heterogeneous Feature Embedding
猜你喜欢

Call the open source video streaming media platform dawinffc

Raspberry pie drum set WiFi

JS label syntax jumps out of multiple loops

港股上市公司移卡收购创信众42.5%股权 谋划加快营销服务布局
![[论文阅读笔记] Network Embedding with Attribute Refinement](/img/71/760f29f8a13b366cf3bad4fb48bd63.jpg)
[论文阅读笔记] Network Embedding with Attribute Refinement

一个名为不安全的类Unsafe

图-无向图

MultiBank Group宣布创纪录的财务业绩,2020年前三季度毛利达到9,400万美元

Taulia推出国际支付条款数据库

Assign the corresponding key and value in the map to the object
随机推荐
[论文阅读笔记] Network Embedding with Attribute Refinement
从大专生到蚂蚁金服CTO,他写下“支付宝”第一行代码:逆风的方向,更适合飞翔!...
商品管统——采购需求合并到采购单
使用call、apply和bind解决js中烦人的this,事件绑定时的this和传参问题
[paper reading notes] network embedding with attribute refinement
Use call, apply and bind to solve the annoying this in JS, this in event binding and parameter passing
寻找性能更优秀的不可变小字典
Mongodb index management of distributed document storage database
CSDN bug8: to be added
Simple use of JMeter
对于程序员,那些既陌生又熟悉的计算机硬件
竞争性编程的思考:那些神话和令人震惊的事实[图]
csdn bug5:待加
分布式文档存储数据库之MongoDB索引管理
delete、truncate、drop 有什么区别,误删数据怎么办
【技术教程】Visual Studio 2017自建WebRTC中peerconnection_client程序报LNK2019 无法解析的外部符号错误
小度“破圈”提速,IoT迎来新故事
世界上最伟大的10个公式,其中一个人尽皆知
【技术教程】C#控制台调用FFMPEG推MP4视频文件至流媒体开源服务平台EasyDarwin过程
工厂方法模式