20251101
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36616.10 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CS4_1", "CS4_1.csproj", "{176395D4-286A-4CFB-8CA6-ABB8FC8E2144}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{176395D4-286A-4CFB-8CA6-ABB8FC8E2144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{176395D4-286A-4CFB-8CA6-ABB8FC8E2144}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{176395D4-286A-4CFB-8CA6-ABB8FC8E2144}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{176395D4-286A-4CFB-8CA6-ABB8FC8E2144}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9BE27323-1DB1-4334-A15D-B183D58010C3}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
namespace CS4_1
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
int min, max, sum = 0, average;
|
||||
int[] A = new int[10];
|
||||
Random rand = new Random();
|
||||
for (int i = 0; i < A.Length; i++)
|
||||
{
|
||||
A[i] = rand.Next(1, 101);
|
||||
}
|
||||
Console.WriteLine("原始数组为:");
|
||||
foreach (var item in A)
|
||||
{
|
||||
Console.Write("{0,4}", item);
|
||||
}
|
||||
min = max = A[0];
|
||||
for (int i = 0; i < A.Length; i++)
|
||||
{
|
||||
if (A[i] < min) min = A[i];
|
||||
if (A[i] > max) max = A[i];
|
||||
sum += A[i];
|
||||
}
|
||||
average = sum / A.Length;
|
||||
Console.WriteLine("\n数组的最小值为:{0}", min);
|
||||
Console.WriteLine("数组的最大值为:{0}", max);
|
||||
Console.WriteLine("数组的平均值为:{0}", average);
|
||||
// 元素降序排序
|
||||
int n = A.Length;
|
||||
for (int i = 0; i < n - 1; i++)
|
||||
{
|
||||
for (int j = 0; j < n - 1 - i; j++)
|
||||
{
|
||||
if (A[j] < A[j + 1])
|
||||
{
|
||||
int temp = A[j];
|
||||
A[j] = A[j + 1];
|
||||
A[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("数组元素降序排序后为:");
|
||||
foreach (var item in A)
|
||||
{
|
||||
Console.Write("{0,4}", item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user