找字串 运行错误 怎么解决?

找子串个数,提交oj平台总是说运行错误,可是自己编译没问题啊,qiu'jie

#include<iostream>
#include<algorithm>
#include<string>


using namespace std;
int main()
{
    int j = 0, cnt = 0;
    string s1, s2;
    getline(cin,s1);
    while (getline(cin,s2))
    {
        for (unsigned int i = 0; i < s2.length() - s1.length() + 1;)
        {
            if (s2[i] == s1[j])
            {
                unsigned int k, count = 0;
                for (k = 0; k < s1.length() && s2[i] == s1[j]; i++, k++, j++)
                {
                    count++;
                }
                if (count == s1.length())
                {
                    cnt++;
                }count = 0; j = 0;
            }
            else 
                i++;
        }
    }
    cout << cnt;
    return 0;
}
0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
运行错误怎么解决?
Datawindow errorrn显示rndatabase transaction infomations not availablerncall settrans or settransobject functionrn怎么办?代码什么都没错误啊..我检查过了。..555555rn谢谢帮助
运行错误怎么解决啊
我用vs2008编写c++程序,我的程序定义_ConnectionPtr pConn;没有错rn一添加pConn.CreateInstance(__uuidof(Connection))能通过编译,但运行错误rnThis application has requested the Runtime to terminate it in an unusual way.rnPlease contact the application's support team for more information.rn不知道怎么办,跪求解决啊
asp.net运行错误 怎么解决?
我做的程序一运行就出现这样的错误 怎么去解决这个问题?rnrn“/MyBMS”应用程序中的服务器错误。rn--------------------------------------------------------------------------------rnrn配置错误 rn说明: 在处理向该请求提供服务所需的配置文件时出错。请检查下面的特定错误详细信息并适当地修改配置文件。 rnrn分析器错误信息: 访问被拒绝:“microsoft.web.ui.webcontrols”。rnrn源错误: rnrnrn行 196: rn行 197: rn行 198: rn行 199: rn行 200: rn rnrn源文件: c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config 行: 198 rnrn程序集加载跟踪: 下列信息有助于确定程序集“microsoft.web.ui.webcontrols”无法加载的原因。rnrnrn=== Pre-bind state information ===rnLOG: DisplayName = microsoft.web.ui.webcontrolsrn (Partial)rnLOG: Appbase = file:///c:/inetpub/wwwroot/MyBMSrnLOG: Initial PrivatePath = binrnCalling assembly : (Unknown).rn===rnrnLOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).rnLOG: Post-policy reference: microsoft.web.ui.webcontrolsrnLOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/mybms/a5242d1a/9cdf0cc7/microsoft.web.ui.webcontrols.DLL.rnLOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/mybms/a5242d1a/9cdf0cc7/microsoft.web.ui.webcontrols/microsoft.web.ui.webcontrols.DLL.rnLOG: Attempting download of new URL file:///c:/inetpub/wwwroot/MyBMS/bin/microsoft.web.ui.webcontrols.DLL.rnLOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).rnLOG: Post-policy reference: Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=nullrnrn rnrnrn--------------------------------------------------------------------------------rn版本信息: Microsoft .NET Framework 版本:1.1.4322.2032; ASP.NET 版本:1.1.4322.2032
这个运行错误如何找?
现象:程序在退出时出现非法操作rn在Debug状态下运行,退出时,开发环境报出了在forms.hpp中的TForm的析构函数出错,但我的程序中有很多窗体,不知道是哪一个窗体对象析构时出错?有什么好的办法可以知道是哪一个窗体调用的这个析构函数吗?
strpos找第二个符合字串
rnrn这个可以取第二个01N06484的位置rnrn但变了找"N06484"这个便不行了rnrnrnrn为何不行?rn有什么办法找第二个的"N06484"的位置?谢谢rn
iis运行错误!怎么解决?急!!!谢谢!
技术信息(用于支持人员)rnrn错误类型:rnMicrosoft VBScript 运行时错误 (0x800A01AD)rnActiveX 部件不能创建对象rn/HY/EYULE/HIT/include/conn.asp, 第 5 行rnrnrn浏览器类型:rnMozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 2.0.40607) rnrn网页:rnGET /HY/EYULE/HIT/index.asp rnrn时间:rn2004年9月25日, 0:16:30 rnrnrn详细信息:rnMicrosoft 支持
android程序运行错误,不知道怎么解决。
我的安卓程序突然运行终止,logCat错误信息如下:nn```n 05-26 10:49:54.540: E/AndroidRuntime(30584): java.lang.OutOfMemoryErrorn05-26 10:49:54.540: E/AndroidRuntime(30584): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)n05-26 10:49:54.540: E/AndroidRuntime(30584): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:527)n05-26 10:49:54.540: E/AndroidRuntime(30584): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:301)n05-26 10:49:54.540: E/AndroidRuntime(30584): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:326)nn05-26 10:49:54.540: E/AndroidRuntime(30584): at android.app.Activity.dispatchActivityResult(Activity.java:5274)n05-26 10:49:54.540: E/AndroidRuntime(30584): at android.app.ActivityThread.deliverResults(ActivityThread.java:3158)n05-26 10:49:54.540: E/AndroidRuntime(30584): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3205)n05-26 10:49:54.540: E/AndroidRuntime(30584): at android.app.ActivityThread.access$1100(ActivityThread.java:136)n05-26 10:49:54.540: E/AndroidRuntime(30584): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1249)n05-26 10:49:54.540: E/AndroidRuntime(30584): at android.os.Handler.dispatchMessage(Handler.java:99)n05-26 10:49:54.540: E/AndroidRuntime(30584): at android.os.Looper.loop(Looper.java:137)n05-26 10:49:54.540: E/AndroidRuntime(30584): at android.app.ActivityThread.main(ActivityThread.java:4881)n05-26 10:49:54.540: E/AndroidRuntime(30584): at java.lang.reflect.Method.invokeNative(Native Method)n05-26 10:49:54.540: E/AndroidRuntime(30584): at java.lang.reflect.Method.invoke(Method.java:511)n05-26 10:49:54.540: E/AndroidRuntime(30584): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:804)n05-26 10:49:54.540: E/AndroidRuntime(30584): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:571)n05-26 10:49:54.540: E/AndroidRuntime(30584): at dalvik.system.NativeStart.main(Native Method)nn```n这个最错误的原因是什么?怎么可以解决?求大神。n
IIS中有关运行错误怎么解决?
Microsoft JET Database Engine (0x80040E09)rn不能更新。数据库或对象为只读。rn
怎么解决ASP.NET运行错误:allowDefinition='MachineToApplication'错误?
ASP.NET运行错误:在应用程序级别之外使用注册为allowDefinition='MachineToApplication'的节是错rnrn误的。如果在IIS中没有将虚拟目录配置为应用程序,则可能导致此错误。rnrn怎么解决ASP.NET运行错误:allowDefinition='MachineToApplication'错误?
eclipse运行错误,高手看看怎么解决,谢谢!!
eclipse运行错误提示:rnlog4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).rnlog4j:WARN Please initialize the log4j system properly.rnException in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerErrorrn at org.hibernate.cfg.Configuration.reset(Configuration.java:168)rn at org.hibernate.cfg.Configuration.(Configuration.java:187)rn at org.hibernate.cfg.Configuration.(Configuration.java:191)rn at com.mwq.hibernate.HibernateSessionFactory.(HibernateSessionFactory.java:16)rn at com.mwq.hibernate.BaseDao.queryList(BaseDao.java:29)rn at com.mwq.hibernate.Dao.queryManagerOfNatural(Dao.java:141)rn at com.mwq.frame.LandFrame.(LandFrame.java:100)rn at com.mwq.PersonnelManage.land(PersonnelManage.java:32)rn at com.mwq.PersonnelManage$1.run(PersonnelManage.java:26)rn at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)rn at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)rn at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)rn at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)rn at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)rn at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)rn at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)rn at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)rnCaused by: java.lang.NullPointerExceptionrn at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:144)rn at org.hibernate.cfg.Environment.(Environment.java:524)rn ... 17 morern问题出在哪里?怎么解决?rn
这个运行错误怎么能解决?
总是出现:temp.exe 中的 0x004122b6 处最可能的异常: 0xC0000005: 读取位置 0x003a7000 时发生访问冲突rntemp.exe 中的 0x004122b6 处未处理的异常: 0xC0000005: 读取位置 0x003a7000 时发生访问冲突!rn这是什么原因/??rn
Kotlin 集成与运行错误的解决
[已解决]Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details 在集成后如果出现了这个异常,请看文章重新检查你有没有什么地址漏掉了
SCTP编译运行错误及解决
在学习使用SCTP之前,你要确定操作系统是否安装了SCTP协议的相关库文件。我使用的是Ubuntu,安装方法如下:sudo apt-get install libsctp-dev lksctp-tools当你安装成功后,可以用如下代码来测试SCTP服务器,这是一个简单的回射服务:sctp_darn -H 0 -P 2500 -l然后打开另一个终端,输入下面的代码来启动一个客户端:sctp_darn
联入数据库 程序运行错误 找原因
我做的是一个 查询程序 联入oracle 数据库 程序在别的机子上运行正确 到我机子上确错了 运行程序 报错 是 project Project1.exe raised exceptioin class EDBEngineerror with message 'An error occurred while attempting to initialize the Borland Database Engine(error $2501)'rnprocess stopped.Use Step or Run to continue.rn怎么解决? 在线等 多谢了
VC++运行错误怎么调试
在编译连接都正确的情况下,怎么调试运行错误,望高手交流经验!
怎么将字串 \u4E00 转字串 "\u4E00"
怎么将字串 \u4E00 转字串 "\u4E00"rnrn我想将字串的 unicode 代码
[已解决]软件测试:Jmeter运行错误
2017/07/14 18:25:49 INFO  - jmeter.threads.JMeterThread: Thread finished: 线程组 1-19 2017/07/14 18:25:50 INFO  - jmeter.threads.JMeterThread: Thread started: 线程组 1-20 2017/07/14 18:25:50 ERROR - j
请问如何解决这个运行错误
各位高手,小弟的DELPHI 6 好象有点问题,新建一个工程之后运行他会出现rn[FATAL ERROR] PROJECT1。DPR(1):FILE NOT FOUND ‘SYSTEM。PAS‘rn好象DELPHI 坏了,但我不想重装有没有什么好办法?rnrn谢谢!
adb.exe 程序运行错误的解决(转载)
NULL 博文链接:https://andli.iteye.com/blog/1226610
一个运行错误急求解决
用RTI和DX写了个程序。。。发现有的机子能正常运行有的机子不能运行。。。不能运行的机子上点击应用程序会报这样一个错rnFile:F:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpprnline:52rnrnExpression:BLOCK_TYPE_IS_VALID(pHead->nBlockUse)rnFor information on how your program can cause an assertion failure,see the Visual C++ documentation on assertsrn这是怎么回事???望高手指教
解决VS2016中Scanf运行错误
1.   error C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 解决方法:在VS中新建项目的时候去...
80080005服务器运行错误 如何解决
我用的是XP系统rn  我的服务器组件com出现了80080005服务器运行错误 rn 造成了我的IIS不能正常运行。rn  请问要怎么解决这个80080005的服务器问题我造成的IIS错误
jsp运行错误!!!!帮忙解决一下
我在运行JSP页面时,出现以下提示:rnHTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: Unable to compile class for JSPrnrnGenerated servlet error:rnD:\JSP\Tomcat 5.0\work\Catalina\localhost\hospital\org\apache\jsp\doctor\getPatientHistory_jsp.java:253: handlePageException(java.lang.Exception) in javax.servlet.jsp.PageContext cannot be applied to (java.lang.Throwable)rn if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);rn ^rn1 errorrnrnrnrn org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)rn org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)rn org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.rnrnrn--------------------------------------------------------------------------------rnrnApache Tomcat/5.0.28rnrnrn请问是什么原因?如何解决?
运行错误,如何解决?高分相求!
做的程序是用evc下的mfc做的。在模拟器上rn运行,窗口出现的时候错误提示:××× sample:file wincore.cpp,Line 1034.rn但是程序可以运行。rnrnrn而且我发现只要是mfc做的,在模拟器上运行都又这个毛病。rnrn我是 evc3。0+winxp professional
Qt5 运行错误,急求解决!!
用Qt的创建了一个默认的程序。编译连接都通过。在执行exe文件时出错:Failed to load platform plugin "windows". Available platforms are: rnrn[img=http://img.my.csdn.net/uploads/201303/17/1363532610_3418.jpg][/img]rnrn请问我该怎么办?装的Qt是msvs2010的,也装了visual add on的插件。不论是Qt中还是vs2010中的都不行。
HDOJ_1238 Substrings 解题报告
Problem Description You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of th
WINDOWS下,找包含特殊字串的文件的解决办法
  当然,这是因为吾亦碰到了这个问题。今天要找的字串类似:   www-csdn-net   结果加了单引号、双引号都不行。   经过一番搜索,找到了有效的解决办法:   ~&quot;www-csdn-net&quot;     这个方法可能有问题,待研究。...
求一个效率的找字符串字串的方法!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
一个字符串:rn“aaaa bbbbbbbb ccccc ddddddddd eeeeeeee” (之间空格数量不定)rnrnchar *acFindSubString (CString p_pString, int p_iIdx)rnrn rnrn想写个函数。。rnp_pString 为传入的字符串 p_iIdx 为要取得的第几个子串rnrnp_iIdx = 2 就返回 bbbbbbbbrn = 4 就返回 dddddddddrnrn不知道有什么好的方法。。效率高点的rn可以用任何api
找两个字符串中的最大字串
public class Substring rn public static void main(String[] args) rn String s1="abractyeyt";rn String s2="dgdsaeactyey";rn String s4="";rn for(int i=0;i
新手请教c++,在主串中找字串
#includern#includernusing namespace std;rnint const N=20;rnint const M=20;rnint index(char [],char[],int);rnint main()rn char a[M]="dgdjydhjd",b[N]="dgd";rn int h=0,k=index(a,b,h);rn if(k!=0)rn cout<<"主串和子串匹配的位置位于主串的第"<t) return i-t;rn else return 0;rn
运行错误
main()rnrnint a,b;rnint aa[4];rnaa[4]=33,787,45,56,455;rnprintf("aa=%d",aa[1]);rnrnrn运行后,提示aa[4]=33,787,45,56,455;这行有错误哦????
运行错误!
使用该方法:添加-新建项-本地数据库(做好了数据表),数据库连接测试成功。但运行时出现这样的问题:rn在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接) rnrn已经在SQL的外围配置设置中把他的远程连接设置为TCP/IP和named pipes同时允许,只使用tcp/ip也尝试过同样出现这样的错误!已经重新启动数据库引擎服务后,对连接设置所做的更改才会生效。rnrn这是我的代码:(界面是一个Button按钮,和一个listview控件)rnusing System;rnusing System.Collections.Generic;rnusing System.ComponentModel;rnusing System.Data;rnusing System.Drawing;rnusing System.Linq;rnusing System.Text;rnusing System.Windows.Forms;rnusing System.Data.SqlClient;rnnamespace WindowsFormsApplication3rnrn public partial class Form1 : Formrn rn public Form1()rn rn InitializeComponent();rn rn private void Form1_Load(object sender, EventArgs e)rn rn rn SqlConnection conn;rn private void button1_Click(object sender, EventArgs e)rn rn conn = new SqlConnection("server=.;database=Database1;uid=sa;pwd=");rn conn.Open();rn SqlCommand cmd = new SqlCommand();rn cmd.Connection = conn;rn cmd.CommandText = "select * from kk";rn cmd.CommandType = CommandType.Text;rn SqlDataReader sdr = cmd.ExecuteReader();rn while (sdr.Read())rn rn listView1.Items.Add(sdr[1].ToString());rn rn conn.Dispose();rn button1.Enabled = false;rn rn rnrn
运行错误??????
我运行一个应用程序,但却出现“程序非法操作的错误”,说是kernel32.dll错误,请问这是怎么回事? thank u!!!
运行错误?
下面代码编译通过;运行到p = strtok(strMid," ");处出现错误:内存不能为"written"!;请问是怎么回事?rn[code=C/C++]rn #include "stdio.h"rn #include rn void strSplit(char* str,int* strLenFact,unsigned char* commandHexStr)rn rn rn int i=0;rn char *strMid=str;rn char *p;rn p = strtok(strMid," ");rn while ( p )rn rn // printf( "%s\n", p );rn sscanf(p,"%02x",&commandHexStr[i]);rn p = strtok( NULL, " " );rn i++;rn rnrn *strLenFact=i; rn rn rnint main(int argc, char *argv[])rnrn char *ss="01 03 07 9F 00 1C 75 59";rn int strFactLen;rn unsigned char commandHex[8]=0;rn strSplit(ss, &strFactLen,commandHex);rnrn[/code]
运行错误????
我在子窗口里的BUTTON4里添加里rnprocedure Tgysinfo1.Button4Click(Sender: TObject);rnbeginrn free;rnend;rnrn后,运行报错。rn
ArrayList怎么转成字串?
new一个ArrayList,放入多个String对象。rn显示时希望连成字串?rn直接用toString是[.......].rn现在不需[]rn怎么实现?
怎么分割字串符?
我要做一个在线发送邮件程序,用户在文本框中输入多个Email的时候以;号隔开,怎么把带有;号的多个Email地址一个个分离出来?Email地址的个数事先未知,是用户动态输入的。
怎么计算两个字串?
RT```rn比如textbox1里有个值是XSC0001rntextbox2里填的是要去掉的值 比如为XSCrn想得出0001rnVB有办法去掉这个值么?
运行错误!!!
我用jbuilder5编译jsp文件无错运行产生了Location: /workroom.jspInternal Servlet Error:javax.servlet.ServletExceptionrn at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)rn at _0002fworkroom_0002ejspworkroom_jsp_8._jspService(_0002fworkroom_0002ejspworkroom_jsp_8.java:149)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)rn at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)rn at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)rn at org.apache.tomcat.core.Handler.service(Handler.java:286)rn at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)rn at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)rn at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)rn at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)rn at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)rn at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)rn at java.lang.Thread.run(Thread.java:484)rn我再这里做了一个数据庫的连接操作rnrn<% ResultSet rs=link.executeQuery("select * from mz");rn %>rn <%rn dorn %>rn <%out.println(session.getAttribute("name"));%>rn <%rn rn while(!rs.next());rn rs.close();rn %>rn其中DateLink是一个数据库连接的封装Bean
相关热词 c#异步发送kafka c#窗体编号 c# 操作二进制文件 c# 反射 机制 c#线程 窗体失去响应 c#角度转弧度 c# 解析gps数据 c# vs设置 语法版本 c# json含回车 c#多线程demo