新建C#控制台程序项目,简单问题,帮帮忙!谢谢

来源:百度知道 编辑:UC知道 时间:2024/07/02 20:32:13
新建C#控制台程序项目,名称:A学号,在MAIN函数中定义整数数组{1,2,3,4,5,6,7,8,9,10},利用FOR循环和IF语句将数组中的奇数打印出

foreach(int temp in array)
{
if(temp%2 == 1)
print出来啊
}

static void Main()
{
int Arr={1,2,3,4,5,6,7,8,9,10};
for(int i=0;i<Arr.Length-1;i++)
{
if(Arr[i]%2==1)
Console.WriteLine(Arr[i]);
}
}

int[] str ={ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int temp;
for (int i = 0; i < str.Length; i++)
{
temp = str[i] % 2;
if (temp > 0)
{
Console.WriteLine(str[i]);
}
}
Console.ReadLine();
}

//怎么搞那么多!
using System;
using System.Collections.Generic;
using System.Text;

namespace 求奇数
{
class Program
{
static void Main()
{
int[] array = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
for (