0% found this document useful (0 votes)
19 views1 page

Hieu

The document contains 4 code blocks that perform various operations on an array variable a. The first block prints the positive, odd, negative and even numbers in the array. The second block prints the indices of positive and negative numbers. The third block prints the first positive number and breaks. The fourth block finds the largest number by comparing adjacent elements and prints it.

Uploaded by

Lê Hữu Phú
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Hieu

The document contains 4 code blocks that perform various operations on an array variable a. The first block prints the positive, odd, negative and even numbers in the array. The second block prints the indices of positive and negative numbers. The third block prints the first positive number and breaks. The fourth block finds the largest number by comparing adjacent elements and prints it.

Uploaded by

Lê Hữu Phú
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1. Console.

WriteLine("Cac so duong");
for (int j = 0; j < a.Length; j++)
if (a[j]> 0)
{
Console.WriteLine("a[{0}] = {1}", j, a[j]);
}

Console.WriteLine("Cac so le");
for (int j = 0; j < a.Length; j++)
if (a[j] % 2 != 0)
{
Console.WriteLine("a[{0}] = {1}", j, a[j]);
}
Console.WriteLine("Cac so am");
for (int j = 0; j < a.Length; j++)
if (a[j] < 0)
{
Console.WriteLine("a[{0}] = {1}", j, a[j]);
}
Console.WriteLine("Cac so chan");
for (int j = 0; j < a.Length; j++)
if (a[j] %2== 0)
{
Console.WriteLine("a[{0}] = {1}", j, a[j]);
}
2. for (int j = 0; j < a.Length; j++)
if (a[j]> 0)
{
Console.WriteLine("[{0}] ", j);
}
for (int j = 0; j < a.Length; j++)
if (a[j]< 0)
{
Console.WriteLine("[{0}] ", j);
}

3. for (int j = 0; j < a.Length; j++)


if (a[j]> 0)
{
Console.WriteLine("a[{0}] = {1}", j, a[j]);
break:
}
4. int n=a[0];
for (int j = 0; j < a.Length; j++)
{
if(a[j+1]>a[j])
n=Console.ReadLine("a[{0}]={1}",j,a[j])
}
Console.WriteLine("{2}" ,n);

You might also like