杭电OJ1005 不明白错误在哪

Number Sequence

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 187350 Accepted Submission(s): 46661

Problem Description
A number sequence is defined as follows:

f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.

Given A, B, and n, you are to calculate the value of f(n).

Input
The input consists of multiple test cases. Each test case contains 3 integers A, B and n on a single line (1 <= A, B <= 1000, 1 <= n <= 100,000,000). Three zeros signal the end of input and this test case is not to be processed.

Output
For each test case, print the value of f(n) on a single line.

Sample Input
1 1 3
1 2 10
0 0 0

Sample Output
2
5

Author
CHEN, Shunbao

Source
ZJCPC2004

代码如下:
import java.util.*;

public class Main{
private static Scanner in;

public static void main(String[] args) {

in = new Scanner(System.in);
while(in.hasNext())
{
int A = in.nextInt();
int B = in.nextInt();
int n = in.nextInt();
int []a = new int[n+2];
a[1] = 1;
a[2] = 1;
if(n==1||n==2) {
System.out.println(1);;
}
if(A==0&&B==0&&n==0) {
continue;
}
if(A1000&n>1000000000) {
System.exit(0);
}
else if(A>=1&&B<=1000&&n>=3&&n<=1000000000)
{
for(int t = 3;t<=n;t++)
{
a[t] = ((A*a[t-1])+(B*a[t-2]))%7;
if(t==n) {
System.out.println(a[t]);
}
}
}
}
}
}

我输入0 0 0时eclipse显示错误;不明白怎么改,求大神帮忙

3个回答

把对0 0 0的判断拉到前面
if(A==0&&B==0&&n==0) {
continue;
}
放在循环体开头
错在数组下标越界吧,n=0的时候,数组只有a[0],a[1]才对
int []a = new int[n+2];
a[1] = 1;
a[2] = 1;

huruiba
坎特 回复眼里一片海: 回复眼里一片海: 这个题,主要是数组下标是从0开始算的,而函数f从f1 f2这样开始,我贴代码给你,好好学,基础要扎实
一年多之前 回复
m0_37632283
眼里一片海 十分感谢 ; 但是最后在杭电运行显示错误答案。这是我的代码,还是不明白哪里出错了
一年多之前 回复

import java.util.*;

public class Main{
private static Scanner in;

public static void main(String[] args) {

in = new Scanner(System.in);
while(in.hasNext())
{
int A = in.nextInt();
int B = in.nextInt();
int n = in.nextInt();
int []a = new int[n+3];
a[1] = 1;
a[2] = 1;
if(n==1||n==2) {
System.out.println(1);;
}
else if(A==0&&B==0&&n==0) {
continue;
}
else if(A1000&n>1000000000) {
System.exit(0);
}
else if(A>=1&&B<=1000&&n>=3&&n<=1000000000)
{
for(int t = 3;t<=n;t++)
{
a[t] = ((A*a[t-1])+(B*a[t-2]))%7;
if(t==n) {
System.out.println(a[t]);
}
}
}
}
}
}

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int A = in.nextInt();
int B = in.nextInt();
int n = in.nextInt();
int[] a = new int[n + 2];//保存函数值 这里应该是n+2,不是n+3
//数组下标从0开始算
a[0] = 1;//f(1)
a[1] = 1;//f(2)
if (n == 1 || n == 2) {
System.out.println(1);
} else if (A == 0 && B == 0 && n == 0) {
//continue;
break;
} else if (A > 1000 & n > 1000000000) {//这个条件是干什么用的
System.exit(0);
} else if (A >= 1 && B <= 1000 && n >= 3 && n <= 1000000000) {
for (int t = 2; t <= n; t++) {
//int m = t-1;
// f(n) = (A * f(n - 1) + B * f(n - 2)) % 7;
// f(3) = (a * f(2)+ b* f(1))*7
a[t] = ((A * a[t - 1]) + (B * a[t - 2])) % 7;
//System.out.println(a[t]);
if (t == (n - 1)) {//你的错误主要是在这里,t==n是不对的,t是数组的下标,从0开始,而函数f的值从1开始
System.out.println(a[t]);
}
}
}
}

}
m0_37632283
眼里一片海 在t==n时a[t]中的值存放已经是最终的f(n)的值了,这里并没有错误,我调试运行后跟杭电例子的输入输出是一样的。 上方如果a[n]设的是a[n+2]的大小话,那么当n==0的时候,下方a[2]就没有值可以存入了.......
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
杭电OJ1005
#include “iostream” using namespace std; int main() { int a, b, n; int f[50]; while (cin &amp;amp;gt;&amp;amp;gt; a &amp;amp;gt;&amp;amp;gt; b &amp;amp;gt;&amp;amp;gt; n&amp;amp;amp;&amp;amp;amp;a&amp;amp;amp;&amp;amp;amp;b&amp;amp;amp;&amp;amp;amp;n
杭电oj1005
#include &amp;lt;iostream&amp;gt; using namespace std; int f(int A,int B,int n) { //f(A,B,n) = ((A * f(A,B,(n - 1)) + B * f(A,B,(n - 2))) % 7); if(n&amp;gt;2)//(n!=1||n!=2) { return ((A * f(A...
北大OJ1005
#include int main(){ int count; scanf("%d",&count); for(int i=1;icount;i++){ float x,y; scanf("%f %f",&x,&y); printf("Property %d: This property will begin eroding in year %d
split(),不明白错在哪??
rnrn可以得到数组a的长度为5,可为什么不能得出各元素的值(最后一行不能运行)??
不明白错在哪
private const string PARM_TITLE_NAME = "@TitleName";rn private const string SQL_INSERT_TITLE="INSERT INTO VoteTitle value( @TitleName,"false")";rnrn显示的错误是:false应输入";",我不明白是怎么回事rn
不明白错在哪了
Private Sub lkb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lkb.Clickrn Dim di As DataGridItemrn For Each di In Datagrid1.Itemsrn If di.ItemType = ListItemType.Item OrElse di.ItemType = ListItemType.AlternatingItem Thenrn Dim dr As DataRow = ds.Tables("tb").Rows.Find(Datagrid1.DataKeys(di.ItemIndex))rn dr("FCOMID") = CType(di.FindControl("FCOMID"), TextBox).Textrn dr("FCODE") = CType(di.FindControl("FCODE"), TextBox).Textrn dr("FNAME") = CType(di.FindControl("FNAME"), TextBox).Textrn dr("FKIND") = CType(di.FindControl("FKIND"), TextBox).Textrn End Ifrn Nextrn ds.WriteXml(Server.MapPath("~/dept.xml"))rn End Subrnrn错误提示:rnDescription: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. rnrnException Details: System.Data.MissingPrimaryKeyException: Table doesn't have a primary key.rnrnSource Error: rnrnrnLine 55: For Each di In Datagrid1.ItemsrnLine 56: If di.ItemType = ListItemType.Item OrElse di.ItemType = ListItemType.AlternatingItem ThenrnLine 57: Dim dr As DataRow = ds.Tables("tb").Rows.Find(Datagrid1.DataKeys(di.ItemIndex))rnLine 58: dr("FCOMID") = CType(di.FindControl("FCOMID"), TextBox).TextrnLine 59: dr("FCODE") = CType(di.FindControl("FCODE"), TextBox).Textrn rn
不明白的错误
我在提交表单时,出现了Method request 405 错误,意思是不能用POST进行提交,不知怎么回事,望各位高手能予以指点 。
不明白的错误!!!
java.lang.NullPointerExceptionrn at com.caucho.vfs.ReadStream.setEncoding(ReadStream.java:400)rn at com.caucho.server.http.Request.setCharacterEncoding(Request.java:966)rn at com.caucho.server.http.RequestAdapter.setCharacterEncoding(RequestAdapter.java:270)rn at _jsp._service._profileadd__jsp._jspService(_profileadd__jsp.java:26)rn at com.caucho.jsp.JavaPage.service(JavaPage.java:74)rn at com.caucho.jsp.Page.subservice(Page.java:485)rn at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:181)rn at com.caucho.server.http.Invocation.service(Invocation.java:291)rn at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:132)rn at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:212)rn at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:99)rn at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:76)rn at com.caucho.jsp.QPageContext.forward(QPageContext.java:520)rn at _jsp._service._profileaddret__jsp._jspService(/jsp/service/profileaddret.jsp:56)rn at com.caucho.jsp.JavaPage.service(JavaPage.java:74)rn at com.caucho.jsp.Page.subservice(Page.java:485)rn at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:181)rn at com.caucho.server.http.Invocation.service(Invocation.java:291)rn at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:132)rn at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:217)rn at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:159)rn at com.caucho.server.TcpConnection.run(TcpConnection.java:136)rn at java.lang.Thread.run(Thread.java:484)rn这是什么错误?
oj1005递归问题
遇到的问题: 1、采用递归发生内存超限,因此不能直接使用递归 2、次数较大,会发生时间超限,因此需要找到循环次数 说明:循环次数为49,是我看到别人的做法是知道的,至于原因,我也想不通,如果读者知道,欢迎留言 题目链接:http://icpc.njust.edu.cn/Problem/Hdu/1005/ import java.util.Scanner; public class Ma...
百炼OJ1005
描述 Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land, he learned that the state of Louisiana is actually shrinking by 50 squ
文件排序(不明白在哪错了)
一个输入文件如:input.txtrnxfgrnderrnsdfgrn输出文件为:ouput.txtrnderrnsdfgrnxfgrn按ASCII码排序rn这是我的程序,不知在哪错了,得不到正确结果,请高手执教。rn#include rnrnint main()rnrn FILE *F_inputFile,*F_outputFile;rn char ach_tmp[1024],ach_cmp[1024],ach_swap[1024];rn int i_cmp=1,i_switch=1,i_flag=0,i_first=0;rn F_inputFile = NULL;rn F_outputFile = NULL;rn memset(ach_tmp,'\0',1024);rn memset(ach_cmp,'\0',1024);rn if(NULL == (F_inputFile = fopen("\input.txt","rt")))rn rn printf("open file error\n");rn rn if(NULL ==(F_outputFile = fopen("\output.txt","wt")))rn rn printf("create a file error\n");rn rn while(NULL!=fgets(ach_tmp,1024,F_inputFile))rn rn i_cmp=1,i_switch=1,i_flag=0;rn if(NULL==(F_outputFile=fopen("\output.txt","rt",F_outputFile)))rn rn printf("reopen file error\n");rn rn rewind(F_outputFile);rn while(NULL!=fgets(ach_cmp,1024,F_outputFile))rn rn if(strcmp(ach_tmp,ach_cmp)<0)rn rn break;rn rn i_cmp++;rn rn strcpy(ach_swap,ach_tmp);rn fclose(F_outputFile);rn F_outputFile=fopen("\output.txt","rt+",F_outputFile);rn rewind(F_outputFile);rn while(NULL!=fgets(ach_cmp,1024,F_outputFile))rn rn if(1==i_flag)rn rn rewind(F_outputFile);rn fseek(F_outputFile,(i_switch-1)*1024L,0);rn printf("1%s\n",ach_swap);rn fputs(ach_swap,F_outputFile);rn strcpy(ach_swap,ach_cmp);rn rn if(i_cmp==i_switch)rn rn strcpy(ach_swap,ach_cmp);rn rewind(F_outputFile);rn fseek(F_outputFile,(i_switch-1)*1024L,0);rn printf("2%s\n",ach_tmp);rn fputs(ach_tmp,F_outputFile);rn i_flag=1;rn rn memset(ach_cmp,'\0',1024);rn fclose(F_outputFile);rn F_outputFile=fopen("\output.txt","rt+",F_outputFile);rn rewind(F_outputFile);rn fseek(F_outputFile,i_switch*1024L,0);rn i_switch++;rn rn if(NULL==fgets(ach_cmp,1024,F_outputFile))rn rn //fclose(F_outputFile);rn F_outputFile=freopen("\output.txt","at+",F_outputFile);rn rewind(F_outputFile);rn fseek(F_outputFile,0L,2);rn printf("3%s\n",ach_swap);rn fputs(ach_swap,F_outputFile);rn fclose(F_outputFile);rn memset(ach_cmp,'\0',1024);rn rn memset(ach_tmp,'\0',1024);rn rn fclose(F_inputFile);rnrn rn
错误在哪?
VC中提示::rn\c++\返回private的引用\time4.cpp(5) : error C2143: syntax error : missing ';' before ':'rn谁帮我找出来。rn以下是头文件,也就是time4.hrnclass Time1rnpublic:rn Time1(int=0,int =0,int=0);rn void setTime(int,int,int);rn int getHour();rn int &badSetHour(int);rnprivate:rn int hour;rn int minute;rn int second;rn;rn以下是time4.cpp文件rn#include"time4.h"rn#includernrnrnTime1:Time1(int hr,int min,int sec)rnsetTime(hr,min,sec);rnrnvoid Time1:setTime(int h,int m,int s)rnrn hour=(h>=0&&h<24) ? h:0;rn minute=(m>=0&&m<60) ? m:0;rn second=(s>=0&&s<60) ? s:0;rnrnrnint Time1::getHour()return hour;rnrnint &Time1:badSetHour(int hh)rnrn hour=(hh>=0&&h<24)?hh:0;rn return hour;rnrnint main()rnrn Time1 t;rn int &hourRef=t.badSetHour(20);rn cout<<"Hour before modification:"<
错误在哪?
下面是代码:rn----------------------------rn[code=VBScript]rn[color=#FF0000]<%rnif grade=7 thenrnhg_all= " zz_h="" or yw_h="" or sx_h="" or yy_h="" or sw_h="" or ls_h="" or dl_h="" or ty_h="" "rnend ifrnif "&hg_all&" then rnresponse.write" "rnend ifrnresponse.end rn%>[/color][/code]rn--------------------------------rn总是提示下面的错误语句(第39行也就是[color=#0000FF]if "&hg_all&" then [/color]这一句):rnrn[color=#008000]错误类型:rnMicrosoft VBScript 运行时错误 (0x800A000D)rn类型不匹配: '[string: "&hg_all&"]'rn/jyj/km_hkfz_modify_save.asp, 第 39 行[/color]rn
错误在哪
login.javarnpackage bookshop.run;rn/**rn * 管理用户登录的类 rn */rnimport bookshop.util.*;rnpublic class login extends DataBase rn private String username; //登录用户名rn private String passwd; //登录密码rn private boolean isadmin; //是否管理员登录rn private long userid=0; //用户ID号rn public login() throws Exceptionrn super();rn username = "";rn passwd = "";rn isadmin = false;rn rn public String getUsername() rn return username;rn rn public void setUsername(String newusername) rn username = newusername;rn rn public String getPasswd() rn return passwd;rn rn public void setPasswd(String newpasswd) rn passwd = newpasswd;rn rn public boolean getIsadmin() rn return isadmin;rn rn public void setIsadmin(boolean newIsadmin) rn isadmin = newIsadmin;rn rn public long getUserid() rn return userid;rn rn public void setUserid (long uid) rn userid = uid;rn rn /**rn * 获得查询用户信息的sql语句rn * @returnrn */rn public String getSql() rn if (isadmin) rn sqlStr = "select * from bookadmin where adminuser = '" +rn dataFormat.toSql(username) + "' and adminpass = '" +rn dataFormat.toSql(passwd) + "'";rn else rn sqlStr = "select * from shop_user where username = '" +rn username + "' and password = '" + passwd + "'";rn rn return sqlStr;rn rn /**rn * 执行查询rn * @returnrn * @throws java.lang.Exceptionrn */rn public boolean excute() throws Exception rn boolean flag = false;rn DataBase db = new DataBase();rn db.connect();rn stmt = db.conn.createStatement ();rn rs = stmt.executeQuery(getSql());rn if (rs.next())rn if (!isadmin)rn rn userid = rs.getLong("id");rn rn flag = true;rn rn rs.close();rn return flag;rn rn;rnrnrn<%@ page session="true" %>rnrn<%rnString mesg = "";rnrnif( request.getParameter("username")!=null && !request.getParameter("username").equals(""))rn String username =request.getParameter("username");rn String passwd = request.getParameter("passwd");rn username = new String(username.getBytes("ISO8859-1"));rn passwd = new String(passwd.getBytes("ISO8859-1"));rn login.setUsername(username);rn login.setPasswd(passwd);rn out.print(username+passwd);rn if (login.excute())rn session.setAttribute("username",username);rn String userid = Long.toString(login.getUserid());rn session.setAttribute("userid",userid);rn response.sendRedirect("booklist.jsp");rn %>rn<% rn else rn mesg = "登录出错!" ;rn rnrn%>rn<%@include file="/bookshop/inc/head.inc"%>rnrn rn 用户登录 rn rn<% if (!mesg.equals(""))rn out.println(" " + mesg + "");%>rn rn rn rn rn 用户名: rn rn rn rn rn rn rn 密码:rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn 测试用户:wxy 密码:wxyrn rn rn rn rn rn rn 如果你还不是本站用户,请在此注册rn rn rn rn rn <%@include file="/bookshop/inc/tail.inc"%>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 JSPrnrnAn error occurred at line: 3 in the jsp file: /bookshop/login.jsprnrnGenerated servlet error:rn [javac] Compiling 1 source filernrnC:\Tomcat5.0\work\Catalina\localhost\_\org\apache\jsp\bookshop\login_jsp.java:48: package bookshop.run does not existrn bookshop.run.login login = null;rn ^rnrnrnrnAn error occurred at line: 3 in the jsp file: /bookshop/login.jsprnrnGenerated servlet error:rnC:\Tomcat5.0\work\Catalina\localhost\_\org\apache\jsp\bookshop\login_jsp.java:50: package bookshop.run does not existrn login = (bookshop.run.login) pageContext.getAttribute("login", PageContext.PAGE_SCOPE);rn ^rnrnrnrnAn error occurred at line: 3 in the jsp file: /bookshop/login.jsprnrnGenerated servlet error:rnC:\Tomcat5.0\work\Catalina\localhost\_\org\apache\jsp\bookshop\login_jsp.java:53: package bookshop.run does not existrn login = (bookshop.run.login) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "bookshop.run.login");rn ^rn3 errorsrnrnrn org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)rn org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)rn org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:413)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:856)rnrnrnnote The full stack trace of the root cause is available in the Tomcat logs.rnrnrn--------------------------------------------------------------------------------rnrnApache Tomcat/5.0.12rn
错误在哪?!
#include rn#include rnrnvoid enter(int a[],int n)rnrn int i;rn for(i=0;ia[middle]) left=middle+1;rn else right=middle-1;rn rn return -1;rnrnrnint main()rnrn void enter(int a[],int n);rn int search(int a[],int n);rn int a[10],n;rn printf("请输入测试数据数目n:");rn scanf("%d",&n);rn enter(a,n);rn printf("查找的坐标i:");rn search(a,n);rn printf("\n");rnrn前面运行正确,但无法输入坐标值。急啊,请大家分析一下。
搞不明白的错误,求助
错误信息:rn--------------------Configuration: 1 - Win32 Debug--------------------rnCompiling...rn1.cpprnLinking...rn1.obj : error LNK2001: unresolved external symbol "bool __cdecl insert(struct node *,int,char)" (?insert@@YA_NPAUnode@@HD@Z)rnDebug/1.exe : fatal error LNK1120: 1 unresolved externalsrn执行 link.exe 时出错.rnrn1.exe - 1 error(s), 0 warning(s)rnrn代码:rn[code=c]#include rn#include rnrn#define N 100rnstruct linkNode;rnstruct nodern char name;rn linkNode *next;rn;rnstruct linkNodern linkNode *next;rn node *node;rn;rnint main()rn node arr[N];rn int counter=0,positionA,positionB;rn char nameA,nameB;rnrn bool isset(node* arr,int length,char name);rn bool insert(node* arr,int length,char name);rn bool add(node* arr,int now,int next);rn int find(node* arr,const int length,char name);rnrn while(true && counter=N)rn return false;rn rn arr[++(*length)].name = name;rn arr[*length].next = NULL;rn return true;rnrnrnbool isset(node* arr,int length,char name)rn int i;rn for(i=0;i
什么错误呀,不明白
我有两个程序碰到相同的错误 如下rnpublic class ChoiceTest extends MIDlet implements CommandListenerrnrn ^rnrn1 errorrnrncom.sun.kvem.ktools.ExecutionExceptionrnrnBuild failedrn并且 public void startApp()rn public void pauseApp()rn public void destroyApp(boolean unconditional)rn都有没问题吧,怎么会事rnrn
出现如下错误,不明白
Buildrn [C++] Module.cpp(1): rn [C++] User.cpp(1): rn [C++] Co.cpp(1): rn [C++] New.cpp(1): rn [C++] History.cpp(1): rn [C++] PubData.cpp(1): rn [C++] InputMachModu.cpp(1): rn [C++] ErrorCommu.cpp(1): rn [C++] CommuData.cpp(1): rn [C++] TCommu.cpp(1): rn [C++] ChangeMachUse.cpp(1): rn [C++] PasswIn.cpp(1): rn [C++] PasswChange.cpp(1): rn [C++] DelTable.cpp(1): rn [C++] ShowAddress.cpp(1): rn [C++] PasswInCo.cpp(1): rn [C++] ErrorCommuModule.cpp(1): rn [C++] TrouProtect.cpp(1): rn [C++] Logo.cpp(1): rn [Linker] rn [Linker Error] Unresolved external '_BeforeDestruction' referenced from F:\MODULE\MODULE.OBJrn [Linker Error] Unresolved external '_ClassDestroy' referenced from F:\MODULE\MODULE.OBJrn [Linker Error] Unresolved external '_ClassCreate' referenced from F:\MODULE\LOGO.OBJrn [Linker Error] Unresolved external '_AfterConstruction' referenced from F:\MODULE\MAIN.OBJrn [Linker Error] Unresolved external 'memset' referenced from F:\MODULE\NEW.OBJrn [Linker Error] Unresolved external '_ftol' referenced from F:\MODULE\HISTORY.OBJrn [Linker Error] Unresolved external 'pow' referenced from F:\MODULE\HISTORY.OBJrn [Linker Error] Unresolved external 'strlen' referenced from F:\MODULE\PASSWCHANGE.OBJrn [Linker Error] Unresolved external '_Return_unwind' referenced from F:\MODULE\MAIN.OBJrn
转换错误,不明白啊···
这个程序为什么会发生这种错误呢?rn[code=Java]rnException in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JPanel cannot be cast to javax.swing.JLabelrn[/code]rnrn奇怪啊,我是按照教程来的,为什么教程可以我不可以呢?rn难道是JDK版本问题,不应该啊~~!!!rnrn[code=Java]JLabel jl=(JLabel)e.getSource();[/code]rnrn这一句,是否错误的啊,不能强制转换么~~~rnrn我急rnrn谢谢各位了 O(∩_∩)O~
看下这个错误不明白了。
package Test;rnimport java.io.*;rnimport javax.swing.*;rnpublic class Test rn public static void main(String[] args) rn try rn FileInputStream fis=new FileInputStream("D:\1.txt");rn FileOutputStream fos=new FileOutputStream("D:\2.txt",true);rn byte[] b=new byte[1024];rn int i=0;rn while(true)rn i=fis.read();rn if(i==-1) break;rn elsern fos.write(b,0,i);rn rn rn fis.close();rn fos.close();rn catch (Exception e) rn e.printStackTrace();rn rn rnrn提示我的错误是:rnjava.io.FileNotFoundException: D:.txt (文件名、目录名或卷标语法不正确。)rn at java.io.FileInputStream.open(Native Method)rn at java.io.FileInputStream.(Unknown Source)rn at java.io.FileInputStream.(Unknown Source)rn at Test.Test.main(Test.java:8)rn我用Linux下设置好目录是可以的啊.怎么在window下我把路径直接复制过来就不行了。rn另外在问一下在JTextField里边用键盘输入以后怎样才能提取出来.只有用光标监听才可以吗???
LNK错误,不明白
Linking...rnnafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCD.lib(dbgdel.obj)rnnafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadexrnnafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadexrn
附加数据库错误 不明白为什么
--AttachSampleDBrn--Run the script from the master database.rnUSE masterrnrn--Update the paths for the data and log files so theyrn--are appropriate for your computer.rnEXEC sp_attach_db @dbname = N'FoodSvc', rn @filename1 = rn N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\FoodSvc_Dat.mdf', rn @filename2 = rn N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\FoodSvc_Log.ldf'rnrnrn老提示设备激活错误。rn物理文件名 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\FoodSvc_Dat.mdf' 可能有误。rnrn可我DATA文件夹里FoodSvc_Log FoodSvc_Dat 都存在呀 rnrn
关于连接数据库的错误,不明白???
下面是代码片断:rnrnOleDbConnection Conn;rnOleDbCommand Cmd;rnOleDbDataReader DR;rnrnstring ConnString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\SimpleArticleSystem\DB070226.mdb";rnConn = new OleDbConnection(ConnString);rnConn.Open();rnrnCmd = new OleDbCommand();rnCmd.Connection = Conn;rnCmd.CommandType = CommandType.Text;rnCmd.CommandText = "Select LanguageID From Language Where Default = True Order By LanguageID";rnrnDR = Cmd.ExecuteReader();rnrn运行到最后一句的时候总会提示:rn“IErrorInfo.GetDescription 因 E_FAIL(0x80004005) 而失败。”错误。为什么呢?rn数据库联接串和SQL语句应该都是没有问题的。。。rn数据库没有设置密码,文件访问权限应该也是没有问题的。rn
不明白的错误,请指教!!!!!!!
一个非常简单的ASP代码,但不知道这错误如何解决:网页无法显示 HTTP 405 - 资源被禁止 Internet 信息服务rnrn<%@LANGUAGE="VBSCRIPT" CODEPAGE="CP_ACP"%>rn <%rn if request.Form("submit")<>"" thenrn id=request.Form("s_id")rn name=request.Form("s_name")rn age=request.Form("s_age")rn sex=request.Form("s_sex")rn rn set conn=server.CreateObject("adodb.connection")rn conn.open "driver=SQL Server;server=(local);uid=sa;pwd=;database=student"rn set rs=server.CreateObject("adodb.connection")rn rs.open "student",conn,1,3rn rs.addnewrn rs("sid")=idrn rs("sname")=namern rs("sage")=agern rs("ssex")=sexrn rs.updatern rs.closern response.Write("记录已经成功添加")rn response.Endrn end ifrn%>rn rn rn rn 增加记录到好友表中rn rn rn 学号:rn rn rn rn 姓名:rn rn rn rn 性别:rn rn 男rn rn 女rn rn rn 年龄:rn rn rn rn rn rn rn rn rn rnrnrn
有个错误不明白!!!!
错误类型:rnMicrosoft OLE DB Provider for ODBC Drivers (0x80040E21)rn多步 OLE DB 操作产生错误。如果可能,请检查每个 OLE DB 状态值。没有工作被完成。rn/kehusave.asp, 第 11 行rn
代码提示错误,我不明白。
<%rn Dim userrn Dim flagrn Dim pwdrn Dim sayrnrn Response.buffer = truern Response.ContentType = "text/HTML"rn Response.Charset = "gb2312"rn user = Request.Form("username")rn pwd = Request.Form("password")rn say = Request.QueryString("say")rnrn提示:Microsoft VBScript 编译器错误 (0x800A0408)rn/lianxi/lianxi2.asp, 第 8 行rn  Response.Charset="gb2312"rn
不明白什么错误
我定义的模板类AList如下,然后在主函数定义一个对象 AList array(20); 出现以下3句错误rnunresolved external symbol "public: __thiscall AList::~AList(void)" (??1?$AList@H@@QAE@XZ)rnunresolved external symbol "public: __thiscall AList::AList(int)" (??0?$AList@H@@QAE@H@Z)rn 2 unresolved externalsrnrn#ifndef _LIST_H_rn#define _LIST_H_rnrntemplate rnclass AListrnrn private :rn int max_size; //最大的元素个数rn int list_size; //当前元素的个数rn int position; //当前位置的下标rn Elem* array_list; //数组名rnrn public :rn //构造函数rn AList(int max_size = 0);rn //析构函数rn ~AList();rn //将顺序的清空rn void clear();rn //在当前结点后面插入一个新结点rn bool insert(const Elem& e);rn //在最后元素后面插入一个新节点rn bool append(const Elem& e);rn //删除pos位置的结点rn bool remove();rn //重设当前位置,默认重设位置为表头rn bool reset(int pos = 0);rn //把当前位置向前挪动一位rn bool prev();rn //把当前位置向后挪动一位rn bool next();rn //返回当前位置的元素值rn bool get_value(Elem& e) const;rn //打印所有的元素rn void print() const;rnrn;rn#endifrnrnrnrnrn#include "stdafx.h"rn#include rn#include rn#include "AList.h"rnusing namespace std;rnrn//构造函数rntemplate rnAList::AList(int max_size)rnrn assert(max_size > 0);rn this->max_size = max_size;rn this->list_size = 0;rn this->position = 0;rn this->array-list = new Elem[max_size]; rnrn//析构函数rntemplate rnAList::~AList()rnrn delete [] array_list;rnrn//将顺序的清空rntemplate rnvoid AList::clear()rnrn delete [] array_list;rn array_list = new Elem[max_size];rn list_size = 0;rn position = 0;rnrn//在 当前结点 前面插入一个 新结点rntemplate rnbool AList::insert(const Elem& e)rnrn if (list_size == max_size)rn rn return false;rn rnrn for (int i=list_size; i>position; i--)rn rn array_list[i] = array_list[i-1];rn rn array_list[position] = e;rn list_size++;rn return true;rnrn//在最后元素后面插入一个新节点rntemplate rnbool AList::append(const Elem& e)rnrn if (list_size == max_size)rn rn return false;rn rnrn array_list[list_size] = e;rn list_size++;rn return true;rnrnrn//删除当前的结点rntemplate rnbool AList::remove()rnrn if (0 == list_size)rn rn return false;rn rnrn for (int i=position; irnbool AList::reset(int pos)rnrn if ((pos < 0) || (pos > list_size-1))rn rn return false;rn rnrn position = pos;rn return true;rnrnrn//把当前位置向前挪动一位rntemplate rnbool AList::prev()rnrn if (0 == position)rn rn return false;rn rn position--;rn return true;rnrnrn//把当前位置向后挪动一位rntemplate rnbool AList::next()rnrn if ((list_size-1) == position)rn rn return false;rn rn position++;rn return true;rnrnrn//返回当前位置的元素值rntemplate rnbool AList::get_value(Elem& e) constrnrn if (0 == list_size)rn rn return false;rn rn e = array_list[position];rn return true;rnrnrn//打印所有的元素rntemplate rnvoid AList::print() constrnrn if (0 == list_size)rn rn returnlrn rn for (int i=0; i
请求高手,不明白的错误!
access作数据库rn以下代码rnrn tryrn datamodule1.ADOTable1.Active :=true;rn datamodule1.ADOTable1.Append ;rn datamodule1.ADOTable1.FieldByName('书名').AsString :=edit1.Text ;rn datamodule1.ADOTable1.Post;rn showmessage('添加成功!');rn exceptrn datamodule1.ADOTable1.Cancel ;rn showmessage('检查是否添加正确!');rn end;rnrn错在哪rnproject mainsysp.exe raised exception class EOleException with message '由于将在索引、rn主关键字、或关系中创建重复的值,请求对表的改变没有成功。改变该字段中的或包含重复数据的字rn段中的数据,删除索引或重新定义索引以允许重复的值并再试一次。',Process stopped.UsernStep or Run to continue,rnrn
弄不明白的错误
[code=C/C++]rn#include rn#include rnvoid main() rn rn unsigned int sehaddr; rn int *un; rn HMODULE hk = LoadLibrary("KERNEL32.dll"); rn un = (int *)GetProcAddress(hk,"SetUnhandledExceptionFilter"); rn _asmrn rn mov eax,un rn add eax,5 rn mov ebx,[eax] rn mov sehaddr,ebx rn rn printf("the top seh: 0x%x\r\n",sehaddr); rn _getch(); rn return; rn rnrn[/code]rnrn编译是通过的,但执行就出现错误rnCompiling...rn111.cpprnD:\Program Files\Microsoft Visual Studio\MyProjects\111\111.cpp(17) : error C2065: '_getch' : undeclared identifierrn执行 cl.exe 时出错.rnrn111.exe - 1 error(s), 0 warning(s)
一个不明白的错误
是这样的,有两个变量strProject和strPlace,每个变量有为0和不为0两种情况,分别处理如下:rnrnrn if ((strProject!="0")&&(strPlace!="0"))rn rn String strSql2="select * from affair_time where Project="+strProject+" and Place="+strPlace+"";rn resultHt=exectest.execQuery(jdbcURL,jdbcDriver,strSql2);rn session.setAttribute("resultHt",resultHt);rn rn if ((strProject=="0")&&(strPlace=="0"))rn rn System.out.println("the resultHt is.........1111111");rn String strSql2="select * from affair_time where 1=1";rn resultHt=exectest.execQuery(jdbcURL,jdbcDriver,strSql2);rn System.out.println("the resultHt is........." +resultHt);rn session.setAttribute("resultHt",resultHt);rn rn if ((strProject!="0")&&(strPlace=="0"))rn rn String strSql2="select * from affair_time where Project="+strProject+"";rn resultHt=exectest.execQuery(jdbcURL,jdbcDriver,strSql2);rn session.setAttribute("resultHt",resultHt);rn rn if ((strProject=="0")&&(strPlace!="0"))rn rn String strSql2="select * from affair_time where Place="+strPlace+"";rn resultHt=exectest.execQuery(jdbcURL,jdbcDriver,strSql2);rn session.setAttribute("resultHt",resultHt); rn rnrnrnrn这样写的话,程序只运行第一种情况,别的情况它都不执行;rnrn如果把其中的==改为=,那就报如下错:rnrn C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\technologysupport\project\affair_time_jsp.java:95: operator && cannot be applied to java.lang.String,java.lang.Stringrn [javac] if ((strProject="0")&&(strPlace="0"))rn [javac] ^rn [javac] 1 errorrnrnrnrn请问,这是为什么呢?谢谢啦!rn
不明白是什么错误
F:\onLineBookStore\WEB-INF\classes\RegistServlet.java:36: unreported exception java.lang.Exception; must be caught or declared to be thrownrn catch(Exception e)throw e;rn ^
不明白的错误(ADODB.Recordset (0x800A0BB9))
Global:rn rnIndex.asprn<%rnSet rs = Server.CreateObject("ADODB.Recordset")rnSet conn = Application("conn")rn%>rnrn rn 查找朋友rn rn rn rn 账号 密码rn rn 新用户注册 rn<%rnif session("www_id")<>""thenrn%>rn <%=session("www_nickname")%>,欢迎你rn rn rn 上传相片rn rn rn 修改资料rn rn rn rn 浏览信息rn rn rn rn rn 修改密码rn rn rn rn<%rnend ifrn'结束rn%>rn rn rn rn rn 会员信息:rn rn rn rn rn rn<%rn sql="SelecT t_login.*,t_province.c_province_txt FROM t_login INNER JOIN t_photo ON t_login.c_login_id = t_photo.c_login_id INNER JOIN t_province ON t_login.c_earning_id=t_province.c_province_id where t_login.c_login_gender='1' and t_login.c_login_open='1'"rn rs.open sql,conn,3,1rn all_record=rs.recordcountrn if rs.recordcount<>0 thenrn Randomizern idrnd=Int(all_record * Rnd+0)rn if idrnd>=all_record then idrnd=all_record-1rn rs.move idrndrn%>rn rn rn " width="80" height="150">rn rn rn rn 姓名: <%=rs"c_login_name")%> 年龄: <%=(year(date)-year(rs("c_login_birthday")))%> <%order=trim(rs("c_login_order"))btxt="笔友,纯友谊,爱情,婚姻,"order=hsplitbtxt,order)rn %> 交友目的: <%=mid(order,2,len(order)-2)%> 自我介绍: <%=replace(rs("c_login_text"),chr(13)," ")%> rn rn ','dwin','resizable=yes, width=420,height=300,top=150,left=190')">详细信息rn <%rn '是否成功登录,如果成功登录就显示就下例信息rn if session("www_id")<>"" thenrn %> rn ','details','resizable=yes,left=150,top=200,width=500,height=200')">发信息给他rn <%rn end ifrn %>rn rn rn rn rn rn rn rn<%rn end ifrn rs.closern '随机取得一名女会员的信息,且其资料公开rn sql="SelecT t_login.*,t_province.c_province_txt FROM t_login INNER JOIN t_photo ON t_login.c_login_id = t_photo.c_login_id INNER JOIN t_province ON t_login.c_earning_id=t_province.c_province_id where t_login.c_login_gender='0' and t_login.c_login_open='1'"rn rs.open sql,conn,3,1rn all_record=rs.recordcountrn if rs.recordcount<>0 thenrn Randomizern idrnd=Int(all_record * Rnd+0)rn if idrnd>=all_record then idrnd=all_record-1rn rs.move idrndrn%>rn rn rn rn rn rn " width="80"height="150">rn rn rn rn rn rn 姓名:rn <%=rs("c_login_name")%>rn rn rn 年龄:rn <%=(year(date)-year(rs("c_login_birthday")))%>rn rn rn <%rn order=trim(rs("c_login_order"))rn order=hsplit(btxt,order)rn %>rn 交友目的:rn <%=mid(order,2,len(order)-2)%>rn rn rn 自我介绍:rn <%=replace(rs("c_login_text"),chr(13)," ")%>rn rn rn rn rn ','dwin','resizable=yes, width=420,height=300,top=150,left=190')">详细信息rn <%rn '是否成功登录,如果成功登录就显示就下例信息rn if session("www_id")<>"" thenrn %>rn','details','resizable=yes, left=150,top=200,width=500,height=200')">发信息给他rn <%rn end ifrn %>rnrn rn rn rn rn rnrn<%rn end ifrn rs.closern '显示最新五条公告信息rn sql="select top 5 * from t_affiche order by c_affiche_date desc"rn rs.open sq1,conn,3,1rn countrecord=rs.recordcountrn if countrecord<>0 thenrn%>rn rn rn rn 公告信息栏:rn rn rn rn rn rn rn <%rn for I =1 to countrecordrn %>rn rn rn ','hg','scrollbars=yes, width=520,height=400,top=100,left=140')">rn <%=rs("c_affiche_bt")%>rn rn (<%=rs("c_affiche_date")%>)rn rn <%rn rs.movenextrn nextrn %>rn rn 发布公告信息rn rn rn rnrnrn<%rn end ifrn rs.closern%>rn rnrnrnrnrnrn运行时总是提示:“错误类型:ADODB.Recordset (0x800A0BB9) /index.asp, 第 256 行”高人帮忙
一个错误不明白
以下是用gauss.seidel法解联立一次方程,但总是有一个错误,rn好像是double abs()有问题,但去掉后计算就不精确了,清高手指点该如何修改!rn#include "smp.h"rn#define MAXSIZE 3rn#define MAXSIZE1 MAXSIZE+1rnmain()rnrn int i,n=3,count=50,ans;rn static double a[MAXSIZE][MAXSIZE1]=rn 10.0,-5.0,-2.0,3.0,rn -4.0,10.0,-3.0,3.0,rn -1.0,-6.0,10.0,3.0rn ,rn x[MAXSIZE]=0.0,0.0,0.0,rn eps=1.0e-10;rn double res[MAXSIZE];rn double abs();rn rn ans=gauss(n,a,x,count,eps,res);rnrn if(ans==1)rn for(i=0;ii)rn res[i]-=A[j+index]*X[j];rn j++;rn rn i++;rn rn i=0;rn while(i
天啊!错误在哪??
index.jsprnrnrn<%@ page language="java" contentType="text/vnd.wap.wml"%>rn<%@ include file="public.jsp"%>rnrnrn rnrnrn rn<%=BackHomeUrl%> rnrnrnrnpublic.jsp文件rn<%rn //定义本游戏所需各常量rn String HREF_OK_STR = "确定";rn String HomeUrl = "http://wap.uni-info.com.cn/";rn String BackHomeUrl = "返回首页"; rn%>rn运行结果:rnHTTP ERROR:500 INTERNAL SERVER ERRORrn模拟器OPENWAVE6.22rnRESIN3.0和TOMCAT我都试过.rn请你告诉我为什么?好吗?我找不出错误,谢谢!rn
帮我看看错误在哪
[code=JScript]<%rn'On Error Resume NextrnrnFunction ValidSQL() rnValidSQL = True rnDim InvalidrnDim Server_FromrnDim Server_NowrnDim Collection rnrnInvalid = split( "'|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare","|") rnServer_From = Cstr(Request.ServerVariables("HTTP_REFERER"))rnServer_Now = Cstr(Request.ServerVariables("SERVER_NAME"))rnrnSet Collection = Request.QueryString rn rnIf Len(Collection)>4 Then rn For Each Arg In Collection rn For I=0 To Ubound(Invalid) rn If Instr(Collection(Arg),Invalid(I))>0 Then rn ValidSQL = false rn Exit For rn End If rn Next rn rn If ValidSQL = False Then rn Response.Write( "输入中包含非法字符,请重新输入! ") rn Response.End()rn Exit For rn End If rn Next rn End If rnEnd FunctionrnrnCall ValidSQL()rnrnDataURL = "E:\*****\*****\Jx_House@=DB.mdb"rn'Strsql = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataURL rnStrsql = "driver=Microsoft Access Driver (*.mdb);dbq=" & DataURLrnset dbconn=server.createobject("ADODB.CONNECTION")rndbconn.open Strsql rn%>[/code]rn上面是一个DbConn.Inc文件的全部代码,出错导致整个项目大部份运行不过来。特来求助!rn错误类型:rnProvider (0x80004005)rn未指定的错误rn/test1/Inc/DbConn.Inc, 第 41 行rn
求助啊...错误在哪
//complex0.hrn#ifndef complex0_h_rn#define complex0_h_rnclass complexrn double x;rn double y;rnpublic:rn complex() ;rn complex(double, double);rn ~complex() ;rn friend complex operator+(complex &, const complex &);//Addtionrn complex operator-(const complex &);//Substractionrn complex operator*(const complex &);//Multiplicationrn friend complex operator*(double, const complex &);//Multiplication by doublern complex operator~( );//conjugate complex rn friend std::istream & operator>>(std::istream &, complex &);rn friend std::ostream & operator<<(std::ostream &, const complex &);rnrn#endifrnrn//complex0.cpprnrn#include rn#include "complex0.h"rnrnusing namespace std;rnrncomplex::complex( )x=y=0; rnrncomplex::complex(double a, double b)rnrn x=a;rn y=b;rnrnrncomplex operator+(complex &cp1, const complex& cp2)//Addtionrnrn cp1.x+=cp2.x;rn cp1.y+=cp2.y;rnrn return cp1;rnrnrncomplex complex::operator-(const complex &cp2)//Substractionrnrn x-=cp2.x;rn y-=cp2.y;rnrn return *this;rnrnrncomplex complex::operator*(const complex &cp2)//Multiplicationrnrn x*=cp2.x;rn y*=cp2.y;rnrn return *this;rnrnrncomplex operator*(double m, const complex & cp1)//Multiplication by doublernrn complex temp;rnrn temp.x=m*cp1.x;rn temp.y=m*cp1.y;rnrn return temp;rnrnrncomplex complex::operator~( )//conjugate complexrnrn x=-x;rn y=-y;rnrn return *this;rnrn rnistream & operator>>(istream & is, complex& cp1)rnrn cout<<"real: ";rn is>>cp1.x;rn cout<<"img: ";rn is>>cp1.y;rnrn return is;rnrnrnostream & operator<<(ostream & os, const complex& cp1)rnrn os<<"( "<rn#include rn#include rn#includern#include rn#include rn#include "complex0.h"rnrnusing namespace std;rnrnint main( )rnrncomplex a(3.0, 4.0); // initialize to (3,4i)rncomplex c;rncout << "Enter a complex number (q to quit):\n";rnwhile (cin >> c)rnrncout << "c is " << c << '\n';rncout << "complex conjugate is " << ~c << '\n';rncout << "a is " << a << '\n';rncout << "a + c is " << a + c << '\n';rncout << "a - c is " << a - c << '\n';rncout << "a * c is " << a * c << '\n';rncout << "2 * c is " << 2 * c << '\n';rncout << "Enter a complex number (q to quit):\n";rnrncout << "Done!\n";rnrnreturn 0;rnrn
找下错误在哪
import java.io.*;rnpublic class HuiWenrn boolean isHuiWen(char str[],int n)rn rn int net=0;rn int i,j;rn for(i=0,j=n-1;i
麻烦看下错误在哪
rnimport java.io.File;rnimport java.io.FileNotFoundException;rnimport java.io.IOException;rnimport java.io.BufferedInputStream;rnimport java.io.BufferedOutputStream;rnimport java.io.FileInputStream;rnimport java.io.FileOutputStream;rnimport java.io.InputStream;rnrnimport org.apache.commons.io.FileUtils;rnimport org.apache.commons.net.ftp.FTP;rnimport org.apache.commons.net.ftp.FTPClient;rnimport org.apache.commons.net.ftp.FTPClientConfig;rnimport org.apache.commons.net.ftp.FTPConnectionClosedException;rnimport org.apache.commons.net.ftp.FTPFile;rnimport org.apache.commons.net.ftp.FTPReply;rnpublic class MYClient rn private static FTPClient FtpClient = null;rn private static String UserName;rn private static String Password;rn private static String Ip;rn private static int Port;rn public MYClient();rn public static void Setting()rn Port = 21;rn UserName = "admin";rn Password = "12345678";rn Ip = "127.0.0.1";rn rn public static void connectServer()rn tryrn int reply;rn FtpClient = new FTPClient();rn FtpClient.configure(getFtpConfig());rn FtpClient.connect(Ip, Port);rn FtpClient.login(UserName, Password);rn FtpClient.setDefaultPort(Port);rn System.out.print(FtpClient.getReplyString());rn reply = FtpClient.getReplyCode();rn if(!FTPReply.isPositiveCompletion(reply))rn FtpClient.disconnect();rn System.err.println("连接失败!");rn rn elsern System.out.println("连接成功");rn catch(Exception e)rn System.out.println("登录失败");rn e.printStackTrace();rn rn rn private static FTPClientConfig getFtpConfig() rn FTPClientConfig ftpConfig = new FTPClientConfig(FTPClientConfig.SYST_UNIX);rn ftpConfig.setServerLanguageCode(FTP.DEFAULT_CONTROL_ENCODING);rn return ftpConfig;rn rn public static void uploadFile(String localFilePath,String newFileName)rn connectServer();rn BufferedInputStream buffIn = null;rn tryrn buffIn = new BufferedInputStream(new FileInputStream(localFilePath));rn FtpClient.storeFile(newFileName,buffIn);rn catch(Exception e)rn e.printStackTrace();rn finallyrn tryrn if(buffIn!=null)rn buffIn.close();rn catch(Exception e)rn e.printStackTrace();rn rn rn rn public static void closeconnect()rn tryrn if(FtpClient!=null)rn FtpClient.logout();rn FtpClient.disconnect();rn System.out.println("已断开链接!");rn rn catch(Exception e)rn System.out.println("出现错误!");rn e.printStackTrace();rn rn rn public static void listRemoteFiles()rn tryrn FTPFile[] Ftpfile=FtpClient.listFiles();rn for(int i=0;i
这个逻辑错误在哪?
len1和len2是两个集合pHead1和pHead2的长度我写的求这两个集合的交集,赋给一个新链表,不知道为什么到第一个if那儿出错了rnrnrnPNODE dcc2(PNODE pHead1, int len1, PNODE pHead2, int len2)rnrn int i, j, k = 0;rn PNODE pHead = (PNODE)malloc(sizeof(NODE));rn PNODE pTail = pHead;rn pTail->pNext = NULL;rn PNODE p1 = pHead1->pNext;rn PNODE p2 = pHead2->pNext;rnrn for(i=0; idata == p2->data)rn rn break;rn rn k++;rn p2 = p2->pNext;rn rn if (k != len2)rn rn PNODE pNew = (PNODE)malloc(sizeof(NODE));rnrn pNew->data = p1->data;rn pTail->pNext = pNew;rn pNew->pNext = NULL;rn pTail = pNew;rn rn k = 0;rn p1 = p1->pNext;rn rn return pHead;rnrn
这段代码的错误在哪?
[code=java]package day01;rnrnpublic class IfElseDemo rnrn public static void main(String[] args) rn // TODO Auto-generated method stubrn int age=15;rn if(age<16 && age>0);rn System.out.println("未成年");rn else if(age>=16 && age<30)rn System.out.println("青年");rn else if(age>=30 && age<40)rn System.out.println("中年");rn else if(age>=40);rn System.out.println("老年");rn elsern System.out.println("不符合逻辑");rn rn rn rn rn rnrnrn[/code]rn10和16行提示"else"有错误,是什么样的错误?
相关热词 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池 c#5.0 安装程序 c# 分页算法 c# gmail 发邮件 c# 多层文件