一道题不会写 求解 编写程序实现功能:从键盘输入一个字符串和一个字符,若字符串中含有该字符,则输出该字符在字符串中第一次出现的位置(下标值),否则输出“未出现” 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string str=Console.ReadLine();string str2=Console.ReadLine();if(str.IndexOf(str2)>=0)Console.Write(str.IndexOf(str2));或ConsoleKeyInfo cki = Console.ReadKey(); 其实wuyq11大哥的已经是全部了 using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _1{ class Program { static void Main(string[] args) { Console.WriteLine("请输入一个字符"); char ch =Convert .ToChar ( Console.ReadLine()); Console.WriteLine("请输入一串字符"); string str = Console.ReadLine(); int start=str.IndexOf(ch.ToString()); if (start >= 0) { Console.WriteLine(start ); } } }} #include<stdio.h>#define n 20void main(){ int i=0,j=0; char str[n],str1; printf("请输入字符串:"); gets(str); printf("请输入字符:"); scanf("%c",&str1); while(str[i]!='\0') { if(str[i]==str1) { printf("下表值为:%d\n",i); j=1; break; } else i++; } if(j==0) printf(" 未出现!!\n");} c#webService引用问题 请教如何用C#自动实现如下操作 如何挤掉textBox中的任一给定字符,比如空格,[,]等 可不可以把从数据库中调出来的数据在grid中显示的时候加一列编号呢? 怎样把COOKIE赋成NULL? 直接用SQL语句操作数据库,比较运算符能不能用参数带入? 如何获取当地天气信息在网页中显示出来 高分求Visual Studio Tools For Office正式版 菜鸟请教关于调取ini配置文件问题。 有没有人对C#做Client开发感兴趣的朋友(全职),如果有兴趣请给我发简历 在一个form上要显示上千个文字应该用什么控件啊? 如何获取指定长度的文件流
string str2=Console.ReadLine();
if(str.IndexOf(str2)>=0)
Console.Write(str.IndexOf(str2));或
ConsoleKeyInfo cki = Console.ReadKey();
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace _1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入一个字符");
char ch =Convert .ToChar ( Console.ReadLine());
Console.WriteLine("请输入一串字符");
string str = Console.ReadLine();
int start=str.IndexOf(ch.ToString());
if (start >= 0)
{ Console.WriteLine(start );
}
}
}
}
#define n 20
void main()
{
int i=0,j=0;
char str[n],str1;
printf("请输入字符串:");
gets(str);
printf("请输入字符:");
scanf("%c",&str1);
while(str[i]!='\0')
{
if(str[i]==str1)
{
printf("下表值为:%d\n",i);
j=1;
break;
}
else i++;
}
if(j==0) printf(" 未出现!!\n");
}