求一个原代码C#或JAVA来写的

来源:百度知道 编辑:UC知道 时间:2024/05/29 20:37:28
编写一个小程序,接受多个(多个=>2个)命令行参数,统计出这些命令行参数中总共出现了多少个小写的"e"字母.

(意思就是 先输入2段字母 然后算出这2段字母里出现了多少个小写的字母e)

//c#控制台应用程序全部代码,在vs2005中通过,其实实现方法有很多种。
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string str1, str2, str3;
Console.Write("请输入一行字符:\n");
str1 = Console.ReadLine();
Console.Write("请再输入一行字符:\n");
str2 = Console.ReadLine();
str3 = str1 + str2;
int c = 0;
for (int i = 0; i < str3.Length; i++)
{
if (str3[i] == 'e'){ c++;}
}
Console.Write("含字符e的次数一共为:" + c + "\n");
Console.ReadKey();
}
}
}

public static void main(String[] args) {
if (args.length < 2) {
System.err.println("arguments