Given an array of integers,
In other words, let inputArray by an integer array of length 'n'. The solution, computed into outputArray, would be:
for each j from 1 to n2:
outputArr[ j ] = inputArray[0] + inputArray[1] + inputArray[2] + ... + inputArray[j1] + inputArray[j+1] + inputArray[j+2] +...+ inputArray[n1]
for j = 0:
outputArray[0] = inputArray[1] + outputArray[2] + ... + outputArray[n1]
for j = n1
outputArray[n1] = outputArray[0] + outputArray[1] + outputArray[2] + ... + outputArray[n2]
For example, the inputArray: { 1, 2, 3, 4 }
returns outputArray: { 9, 8, 7, 6 }
which is nothing but { 2+3+4, 1+3+4, 1+2+4, 1+2+3 }.
Notes:
The input array size will always have at least two elements in it, that is, n >= 2.
You could treat all the numbers as integers
The maximum length of input array is 100.
Mohammed IbrahimPosted Aug 27, 2015, 12:41 AM
Console.WriteLine("Enter the Array value:");
n=int.Parse(Console.ReadLine());
if(n<100)
{
Console.WriteLine("enter the String one by one;");
int[] values;
values=new int[n];
for(int i=0;i
//get the value one by one
values[i]=int.Parse(Console.ReadLine());
}
// take the value one by one by using the for loop
for(int j=0;j
int sum=0;
for(int i=0;i
if(i!=j)
{
sum = sum +values[i];
}
}
Console.WriteLine("\n"+sum.ToString());
}
}
else
{
Console.WriteLine("Enter the number below 100 and below");
}
Console.ReadKey(true);
ValarmathiPosted Aug 27, 2015, 1:17 AM
Mohammed IbrahimPosted Aug 27, 2015, 1:01 AM
ValarmathiPosted Aug 27, 2015, 12:50 AM
ValarmathiPosted Aug 27, 2015, 12:48 AM
ValarmathiPosted Aug 27, 2015, 12:32 AM
Mohammed IbrahimPosted Aug 27, 2015, 12:27 AM
ValarmathiPosted Aug 27, 2015, 12:15 AM
Mohammed IbrahimPosted Aug 27, 2015, 12:11 AM
ValarmathiPosted Aug 27, 2015, 12:06 AM
Mohammed IbrahimPosted Aug 26, 2015, 11:11 AM
Console.WriteLine("Enter the Array value:");
n=int.Parse(Console.ReadLine());
if(n<100)
{
Console.WriteLine("enter the String one by one;");
int[] values;
values=new int[n];
for(int i=0;i
//get the value one by one
values[i]=int.Parse(Console.ReadLine());
}
// take the value one by one by using the for loop
for(int j=0;j
int sum=0;
for(int i=0;i
if(i!=j)
{
sum = sum +values[i];
}
}
Console.WriteLine("\n"+sum.ToString());
}
}
else
{
Console.WriteLine("Enter the number below 100 and below");
}