3 changed files with 97 additions and 0 deletions
@ -0,0 +1,46 @@ |
|||||
|
|
||||
|
using System; |
||||
|
|
||||
|
public class Program |
||||
|
{ |
||||
|
public static void Main() |
||||
|
{ |
||||
|
int[] A = {-7, 1, 5, 2, -4, 3, 0}; |
||||
|
|
||||
|
int length = A.Length; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
if(length < 3) |
||||
|
{ |
||||
|
System.Console.Write("-1"); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
for(int k=1; k<length; k++) |
||||
|
{ |
||||
|
int sum1=0, sum2=0; |
||||
|
for(int i=0; i<k; i++) |
||||
|
{ |
||||
|
sum1=sum1+A[i]; |
||||
|
|
||||
|
} |
||||
|
for(int j=k+1; j<length; j++) |
||||
|
{ |
||||
|
sum2=sum2+A[j]; |
||||
|
} |
||||
|
if(sum1 == sum2) |
||||
|
{ |
||||
|
System.Console.Write(k); |
||||
|
break; |
||||
|
} |
||||
|
if(k==length) |
||||
|
{ |
||||
|
System.Console.Write("-1"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,43 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace szkola_2._0; |
||||
|
{ |
||||
|
|
||||
|
class Program |
||||
|
{ |
||||
|
|
||||
|
public static void sortowanie(int[] sort;) |
||||
|
{ |
||||
|
int length = sort.length; |
||||
|
do |
||||
|
{ |
||||
|
for(int i=0; i<length-1; i++) |
||||
|
{ |
||||
|
if(sort[i]>sort[i+1]) |
||||
|
{ |
||||
|
int support = sort[i]; |
||||
|
sort[i] = sort[i+1]; |
||||
|
sort[i+1] = support; |
||||
|
} |
||||
|
} |
||||
|
length--; |
||||
|
} |
||||
|
while(length>1); |
||||
|
for(int j = length-1; j >= 0; j--) |
||||
|
{ |
||||
|
Console.Write(sort[j] + ","); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
static void Main(string[] args) |
||||
|
{ |
||||
|
int[] sortowanie = {21, 14, 1, 66, 45}; |
||||
|
|
||||
|
sortowanie(sortowanie[]); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>net5.0</TargetFramework> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
</Project> |
||||
Loading…
Reference in new issue