using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 输出最长串
{
class Program
{
static void Main(string[] args)
{
int no=0;
int max=0;
string arr =Console.ReadLine();
char[] ar = new char[arr.Length];
int i = 0;
foreach (var a in arr)
{
ar[i] = a;
i++;
}
int temp = 0;//保留最长字符串的起始位置
int num = 1;//记录字母数
for (int j = 0; j < ar.Length-1; j++)
{//如果ar[i]和他的下一个都是字符,则将计数加一
if ((ar[j] >= 'a' && ar[j] <= 'z' || ar[j] <= 'Z' && ar[j] >= 'A')&&
(ar[j + 1] <= 'z' && ar[j + 1] >= 'a' || ar[j + 1] <= 'Z'&&ar[j+1]>='A')
&& (ar[j + 1] >= 'A'))
{ num++;if (num > max){ temp = j + 1; max = num; } }
else num = 1;
}
Console.WriteLine("最长字符串长度为:" + max );
Console.Write("它为:");
for (int k = temp-max+1; k < temp+1 ; k++)
Console.Write( arr[k]+"");
Console.Read();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 输出最长串
{
class Program
{
static void Main(string[] args)
{
int no=0;
int max=0;
string arr =Console.ReadLine();
char[] ar = new char[arr.Length];
int i = 0;
foreach (var a in arr)
{
ar[i] = a;
i++;
}
int temp = 0;//保留最长字符串的起始位置
int num = 1;//记录字母数
for (int j = 0; j < ar.Length-1; j++)
{//如果ar[i]和他的下一个都是字符,则将计数加一
if ((ar[j] >= 'a' && ar[j] <= 'z' || ar[j] <= 'Z' && ar[j] >= 'A')&&
(ar[j + 1] <= 'z' && ar[j + 1] >= 'a' || ar[j + 1] <= 'Z'&&ar[j+1]>='A')
&& (ar[j + 1] >= 'A'))
{ num++;if (num > max){ temp = j + 1; max = num; } }
else num = 1;
}
Console.WriteLine("最长字符串长度为:" + max );
Console.Write("它为:");
for (int k = temp-max+1; k < temp+1 ; k++)
Console.Write( arr[k]+"");
Console.Read();
}
}
}