C#网络编程作业题目,应该很简单,不过本人愚笨呐,哪位高手帮个忙啊?感激不尽呀~

作者&投稿:超韩 (若有异议请与网页底部的电邮联系)
D29L 用户们 帮一下忙 问一个愚蠢的问题··~

开机后按“左键”两下 然后 按“M”
进去后 按:“右键”两下 后M

最后再按 M 就OK了

网上有很多资料,去计算机等级考试网

题1
static void Main(string[] args)
{
int num;
int i = 1;
int j = 1;
int x = 1;
for (i = 1; i <= 5;i++ )
{
num = i * i;
Console.WriteLine(num);
}

while (j < 6)
{
num = i * i;
Console.WriteLine(num);
i++;
}

do
{
num = i * i;
Console.WriteLine(num);
i++;
} while (x < 6);
}

题2
public static bool character(string input)
{

if (input.Length != 5)
{
Console.WriteLine("输入长度不符合,请重新输入!");
return false;
}
else if (input == input.ToLower())
{
Console.WriteLine("请输入大写字母!");
return false;
}
else
{
Console.WriteLine("输入成功!");
return true;
}
}

static void Main(string[] args)
{

for (; ; )
{
string input;
Console.WriteLine("请输入五个大写字母");
input = Console.ReadLine();
if (character(input))
{
break;
}
}
}

题3

static void Main(string[] args)
{
for (; ; )
{
int num;
Console.WriteLine("请输入一个数:");
num = int.Parse(Console.ReadLine());
if (num > 0)
{
for (int i = 1; i <= num; i++)
{
Console.Write(i + " ");
}
Console.WriteLine();
}
else
{
Console.WriteLine("程序退出!");
break;
}
}
}

题4 俺数学丑...........汗一个..........

没事做,看看自己还会不会
第一题 static void Main(string[] args)
{
for (int i = 0; i < 5; i++)
{

Console.WriteLine(getx(2)[i].ToString());
}
Console.ReadKey();
}
private static List<int> getx(int flag)
{
List<int> list = new List<int>();
if (flag == 0)
{

for (int i = 1; i < 6; i++)
{
list.Add(i * i);
}

}
else if (flag == 1)
{

int i = 1;
while (i < 6)
{
list.Add(i * i);
i++;
}
}
else if (flag == 2)
{
int i=1;
do { list.Add(i * i); i++; }
while (i < 6);

}
return list;
}

第四题
static void Main(string[] args) {
List<int> perfectNumbers = new List<int>();

for (int i = 2; i <= 1000; i++) {
int[] properDivisors = GetProperDivisor(i);
if (properDivisors.Sum() == i) perfectNumbers.Add(i);
}

foreach (int i in perfectNumbers) Console.Write("{0} ", i.ToString());
}

static int[] GetProperDivisor(int n) {
List<int> divisorList = new List<int>();
divisorList.Add(1);

int maxI = n;
Stack<int> stack = new Stack<int>();
for (int i = 2; i < n; i++) {
if (i >= maxI) break;

if (n % i == 0) {
divisorList.Add(i);
int quotient = n / i;
stack.Push(quotient);
if (quotient < maxI) maxI = quotient;
}
}

int length = stack.Count;
for (int i = 0; i < length; i++) divisorList.Add(stack.Pop());

return divisorList.ToArray();
}

非常简单,就是太多了。


瓦房店市13295314398: C#的一道很简单的题. -
错亭万吉: static void Main(string[] args) { int[] arr = new int[3]; for (int i = 0; i < 3; i++) arr[i] = Int.Parse(Console.ReadLine()); for (int i = 0; i < 3; i++) Console.WriteLine("arr[{0}]={1}", i, arr[i]); }

瓦房店市13295314398: C#编程题目 -
错亭万吉: 第一很简单呀,我不写了,核心代码: string str1 = Console.ReadLine(); string str2 = Console.ReadLine(); if (str1.Contains(str2))//判断包含 {}else{} 第二个:写法很多种呀,看看你要什么样的,我是这么写的: abstract class Emp { abstract public...

瓦房店市13295314398: 几道简单的 c#编程题 求高手帮忙 -
错亭万吉: class person { string _name; string _gender; int _age; int _height; int _weight; public string name { get { return _name; } set { _name = value; } } public string gender { get { return _gender; } set { _gender = value; } } public int age { get { return _age; } ...

瓦房店市13295314398: 求一些简单的c#编程题目和答案 -
错亭万吉: 从1一直加到N(循环) 从1一直乘到N(递归) 把一组整型数组排序(冒泡排序)

瓦房店市13295314398: 一道简单的C#编程题目
错亭万吉: using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace ConsoleApplication1{ class Program { public static bool a = true, b = true, c = true, d = true, e = true;//true代表参加 static void Main(string[] args) { for...

瓦房店市13295314398: 一道简单的C#编程题! -
错亭万吉: 你好,以下是一个示例代码:using System;using System.Text;namespace ConsoleApplication1{ public class Data { public Data(string str) { Console.WriteLi...

瓦房店市13295314398: C#题目很简单,大神帮帮忙 要源代码 从键盘读入20个数据到数组中,统计其中正数的个数,并计 -
错亭万吉: int sum = 0; int k = 0; Console.WriteLine("请输入20个数:"); for (int i = 0; i <20; i++) { string s = Console.ReadLine(); int x = int.Parse(s); if(x>0) { k++; sum += x; } } Console.WriteLine("正数:"+ k); Console.WriteLine("和:" + sum);

瓦房店市13295314398: 简单的一个C# 菜鸟级别的题目.? . -
错亭万吉: 先要判断是整数 public bool IsNumericTry(string str) { try { In32.Parse(str); if(Conver.tostring(txtNumber.Text)10) { MessageBox.Show("输入超出了范围,只能输入1-10 之间,!请重新输入","温馨提示"); } } catch { Message.Show("必须输入整数!"); } }

瓦房店市13295314398: C#简单题写出以下程序运行结果. -
错亭万吉: 没错啊...这个程序是偶数相加.和大于50就跳出. 1+2+3+4+5....+i 取其中的偶数想加,当和大于50时退出 i=15时,整个程序遍历了1到15 取其中的偶数2,4,6,8,10,12,14相加=56 大于50,退出循环

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网