Using a tf.Tensor as a Python bool is not allowed这个报错该如何解决?

TypeError:
Using a tf.Tensor as a Python bool is not allowed. Use if t is not None: instead of if t: to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.

def spiky(x):

r1 = 2/(1+pow(math.e,-x))-1
if r1 <= -1+Amin*W/2:
    return -1.
else:
    return 1.

这是我自己定义的激活函数,输入应该是一个[1,1]的Tensor,问题应该出在这里,但完全不知道如何解决,跪求大佬教教我

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
void f(bool* a)......
void f(bool* a)......rn怎样调用f ?
【C++】bool a:1;这个怎么解释?
Bit field, 位域。意思大概就是你虽然声明自己是个bool(8bit),但我可以只占1bit的空间。#include&amp;lt;iostream&amp;gt; using namespace std; struct S1 { bool b1 :1; bool b11 ;1; bool b111 :1; unsigned a :20; uns...
[Warning] friend declaration `bool operator ==(A &, A &)'
template rnclass Arnrn public:rn A() cout<<"template class A ;"< (A &,A&);//yes.rn friend bool operator == (A &,A &);rn;rntemplate rnbool operator == (A <_T> &a,A <_T> &b)rnrn cout<<"operator == <> (A &,A &)"< bool operator == (A &a , A &b)rnrn cout<<"Partial specialize for tempalte A......"< friend bool operator ==(A&,A&)这个特化声明,就正确了。)rn E:\VisualC++\DEV_C++\friend.cpprn[Warning] friend declaration `bool operator ==(A &, A &)'rn E:\VisualC++\DEV_C++\friend.cpprn[Warning] declares a non-template functionrn E:\VisualC++\DEV_C++\friend.cpprn[Warning] (if this is not what you intended, make surern E:\VisualC++\DEV_C++\friend.cpprn[Warning] the function template has already been declared,rn E:\VisualC++\DEV_C++\friend.cpprn[Warning] and add <> after the function name here)rn E:\VisualC++\DEV_C++\friend.cpprn[Warning] -Wno-non-template-friend disables this warning.rn E:\VisualC++\DEV_C++\friend.cpprntemplate-id `operator ==<>' for `operator ==(A &, A &)' does not match any template declarationrnE:\VisualC++\DEV_C++\friend.cpprnsyntax error before `'
UINavigationControllers are not allowed in a navigation controller
我使用xcode6.1编译一个旧工程,编译可以通过,但是运行的时候出现如下错误:rnTerminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UINavigationControllers are not allowed in a navigation controller!rn程序中用到UINavigationController的地方很多,基本上都是如下形式:rn[code=objc]rn- (IBAction)trendButtonClicked:(id)sender rn TrendListCtrlor *trendList = [[TrendListCtrlor alloc] init];rn trendList.delegate = self;rn UINavigationController *tlNav = [[UINavigationController alloc] initWithRootViewController:trendList];rn [self presentModalViewController:tlNav animated:YES];rn [tlNav release];rn [trendList release];rnrn[/code]rn请问这是什么原因导致的,如何解决
报错: "0.0' is not a valid timestamp'如何解决?
报错 raised exception class EComvertError with message "0.0' is not a valid timestamp'rn谁碰到过???rn D7+SQL2K,三层结构,在插入新记录后对所对应的查询进行刷新,单步执行中不报错,在整个事件结束后就这样提示。(所用的是按钮的单击事件里AddBtnClick)。
Using the TSL2550 with a Microcontroller
Using the TSL2550 with a Microcontroller
Just Like A BlackBoard Using A PictureBox
Just Like A BlackBoard Using A PictureBox
Using Linux As A Router
Using Linux As A Router.pdf
Using AI to Deliver a Device as a Service
Using AI to Deliver a Device as a Service,Using AI to Deliver a Device as a Service
A class that makes using DIBSections as simple as using a CB
A class that makes using DIBSections as simple as using a CBitmap (134KB)
Computer Simulation A Foundational Approach Using Python
Computer simulation is an eective and popular universal tool. It can be applied to almost all disciplines. Typically, simulation involves two key steps: modeling and implementation, which are highlighted in this book. Modeling can performed using event graphs, which are revived by this book. As for implementation, complete Python programs are given, which is considered a new eort. This is an interesting combination as the translation process from models to programs is straightforward.
using Microsoft.Data.Odbc报错如何解决?
using System.Data;rnusing System.Data.Common;rnusing Microsoft.Data.Odbc;rnrn___________________________________rnrn提示using Microsoft.Data.Odbc;中命名空间名称“data”在类或命名空间“Microsoft”中不存在(是否缺少程序集引用)。
++a*++a*++a 这个怎么运算?
为什么这么算啊?rnrna = 1;rnc = ++a*++a*++a;rnrnc的结果是多少。rn我一直以为是:64rnrn我在vc的环境下的出的结果是:36rnrn++和*的运算顺序是怎么弄的。
这个报错该怎么解决
各位前辈:rn  我现在正学编程。可一开始就给难住了。情况是这样的:rn我学习的是《windows 程序设计》第5版。因为刚拿到书不久,所以还没有仔细看,就忙着上机做试验。第三章的试验hellowin.c 这个例程, 我照着编完以后,编译时没有报错,但是当我进行“构建hellowin.exe"时报出了以下的错误:rnrnrnrnrn--------------------Configuration: hellowin - Win32 Debug--------------------rnLinking...rnhellowin.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12rnDebug/hellowin.exe : fatal error LNK1120: 1 unresolved externalsrnError executing link.exe.rnrnhellowin.exe - 2 error(s), 0 warning(s)rnrnrn开始我以为是我编写时,可能什么地方因为粗心了,输入错误,于是在栓查不出来的情况下把原程序给拷了去,再进行构建时还是以上的错误。rnrnrn  我有msdn.但是我的英文阅读能力太差了,越看我头越大。所以就来让前辈们指点一下。rnrn我用的编程工具是 VC++6.0版 。完整的例程如下:rn/*------------------------------------------------------------rn HELLOWIN.C -- Displays "Hello, Windows 98!" in client arearn (c) Charles Petzold, 1998rn ------------------------------------------------------------*/rnrn#include rnrnLRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;rnrnint WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,rn PSTR szCmdLine, int iCmdShow)rnrn static TCHAR szAppName[] = TEXT ("HelloWin") ;rn HWND hwnd ;rn MSG msg ;rn WNDCLASS wndclass ;rnrn wndclass.style = CS_HREDRAW | CS_VREDRAW ;rn wndclass.lpfnWndProc = WndProc ;rn wndclass.cbClsExtra = 0 ;rn wndclass.cbWndExtra = 0 ;rn wndclass.hInstance = hInstance ;rn wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;rn wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;rn wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;rn wndclass.lpszMenuName = NULL ;rn wndclass.lpszClassName = szAppName ;rnrn if (!RegisterClass (&wndclass))rn rn MessageBox (NULL, TEXT ("This program requires Windows NT!"), rn szAppName, MB_ICONERROR) ;rn return 0 ;rn rn hwnd = CreateWindow (szAppName, // window class namern TEXT ("The Hello Program"), // window captionrn WS_OVERLAPPEDWINDOW, // window stylern CW_USEDEFAULT, // initial x positionrn CW_USEDEFAULT, // initial y positionrn CW_USEDEFAULT, // initial x sizern CW_USEDEFAULT, // initial y sizern NULL, // parent window handlern NULL, // window menu handlern hInstance, // program instance handlern NULL) ; // creation parametersrn rn ShowWindow (hwnd, iCmdShow) ;rn UpdateWindow (hwnd) ;rn rn while (GetMessage (&msg, NULL, 0, 0))rn rn TranslateMessage (&msg) ;rn DispatchMessage (&msg) ;rn rn return msg.wParam ;rnrnrnLRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)rnrn HDC hdc ;rn PAINTSTRUCT ps ;rn RECT rect ;rn rn switch (message)rn rn case WM_CREATE:rn PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;rn return 0 ;rnrn case WM_PAINT:rn hdc = BeginPaint (hwnd, &ps) ;rn rn GetClientRect (hwnd, &rect) ;rn rn DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,rn DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;rn EndPaint (hwnd, &ps) ;rn return 0 ;rn rn case WM_DESTROY:rn PostQuitMessage (0) ;rn return 0 ;rn rn return DefWindowProc (hwnd, message, wParam, lParam) ;rnrnrnrnrn我第一次参加csdn,不知道怎么散分。在这里只有先谢过各位前辈了。
这个报错该怎么解决?
错误1 无法创建“DoctorWorkStation\MedicalRecord\frmSubDiseaseTrack.resx”的清单资源名称。未能找到文件“D:\gs_d\hh\test1\iCare_gxqyy\iCare_gxqyy\code\EMR\iCare\DoctorWorkStation\MedicalRecord\frmSubDiseaseTrack.cs”。
mysql Not allowed to return a result set from a trigger
今天在学习mysql时,创建触发器总是不成功报这个错Not allowed to return a result set from a trigger;rn比如这样创建 create trigger newproduct after insert on products for each row select 'd'; 把rnrn后面的返回结果去掉,还是报错:rnERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatrncorresponds to your MySQL server version for the right syntax to use near '' atrnline 1rn有谁知道原因的,帮帮忙
"a"如何转换成'a'?
如题!谢谢
constructors not allowed a return type 这个错误是什么意思?
很简单的rnChannel.h中rnrn#include "winsock.h"rnrnclass CChannel rnrnpublic:rn CChannel();rn ~CChannel();rn int m_serverPort; //服务器的Socket端口rnrnrnrnChannel.cpp中rnCChannel::CChannel()rnrn m_serverPort=0;rnrnrnCChannel::~CChannel()rnrnrnrn为什么会出现 指出在 CChannel::CChannel()处有rnconstructors not allowed a return type 的错误
Operation not allowed on a unidirectional dataset错误?
出现错误提示如题.rn rn http://topic.csdn.net/t/20030712/11/2019908.html 该帖中的方法也试过了. 问题依旧.rnrn出错处代码:rnrn[code=Delphi(Pascal)]rnprocedure Tmain.BitBtn1Click(Sender: TObject);rnbeginrn sqlquery1.Close;rn sqlquery1.SQL.Clear;rn sqlquery1.SQL.Add('select * from Car_into ');rn sqlquery1.Open;rn sqlquery1.ExecSQL();rnrn main.PageControl1.Pages[0].TabVisible:=false;rn main.PageControl1.Pages[1].TabVisible:=false;rn main.PageControl1.Pages[2].TabVisible:=false;rn pagecontrol1.Visible :=true;rn pagecontrol1.ActivePage := Tabsheet1;rnend;rn[/code]rnrn控件关系:rnrnSQLconnection 1 --> dataset 1 rnDataset 1 --> DataSource 1 rnDBgrid 1 --> DataSource 1rnrn问题 :rnrnOperation not allowed on a unidirectional dataset 错误 rnrn http://topic.csdn.net/t/20030712/11/2019908.html 该帖中的方法也试过了. 问题依旧.
struts2 java.lang.IllegalStateException: No modifications are allowed to a locked ParameterMap
系统部署后,从登入界面登入系统的时候,抛出如下异常,请各位帮我解决一下,谢谢 rn奇怪的是我刷新一下就没有问题,就能登入系统了。。刚接触struts2,请大家多多指教 rnrn2008-09-22 15:12:00,218 ERROR (org.apache.struts2.dispatcher.FilterDispatcher:395) - error getting ActionMapping rnjava.lang.IllegalStateException: No modifications are allowed to a locked ParameterMap rnat org.apache.catalina.util.ParameterMap.put(ParameterMap.java:166) rnat org.apache.catalina.connector.Request.getParameterMap(Request.java:1057) rnat org.apache.catalina.connector.RequestFacade.getParameterMap(RequestFacade.java:414) rnat javax.servlet.ServletRequestWrapper.getParameterMap(ServletRequestWrapper.java:166) rnat org.apache.struts2.dispatcher.mapper.DefaultActionMapper.handleSpecialParameters(DefaultActionMapper.java:308) rnat org.apache.struts2.dispatcher.mapper.DefaultActionMapper.getMapping(DefaultActionMapper.java:276) rnat org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:393) rnat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) rnat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) rnat com.my.s2.common.PurviewFilter.doFilter(PurviewFilter.java:47) rnat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) rnat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) rnat org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) rnat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) rnat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) rnat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) rnat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) rnat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) rnat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) rnat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) rnat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) rnat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) rnat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) rnat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) rnat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) rnat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) rnat org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) rnat org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) rnat org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) rnat java.lang.Thread.run(Thread.java:619) rnrnweb.xml的配置如下 rn rn rns2 rn rn rncontextConfigLocation rnclasspath*:spring/*.xml rn rn rn rnencodingFilter rn rnorg.springframework.web.filter.CharacterEncodingFilter rn rn rnencoding rnUTF-8 rn rn rn rnencodingFilter rn/* rn rn rnhibernateFilter rn rnorg.springframework.orm.hibernate3.support.OpenSessionInViewFilter rn rn rn rnhibernateFilter rn*.action rn rnrn rn rnPurview rn rncom.my.s2.common.PurviewFilter rn rn rntoErrorPage rn/commons/error.jsp rn rn rn rnPurview rn*.action rn rnrnrn rn struts2 rn org.apache.struts2.dispatcher.FilterDispatcher rn rn rn struts2 rn /* rn rnrnrn rn rn rnorg.springframework.web.util.IntrospectorCleanupListener rn rn rn rn rn rn org.springframework.web.context.ContextLoaderListener rn rn rnrn rn rn org.apache.myfaces.webapp.StartupServletContextListener rn rn rn rnrn rn dwr rn uk.ltd.getahead.dwr.DWRServlet rn rn debug rn true rn rn rnrn rn dwr rn /dwr/* rn rnrn rn rnValidateCode rn rncom.my.s2.common.ValidateCode rn rn rn rnValidateCode rn/servlet/ValidateCode rn rn rnAppUtil rncom.my.s2.common.AppUtil rn5 rn rnrn rn rn30 rn rn rn index.jsp rn rn rn
constructors not allowed a return type问题
最近在看C++ 看到类这几张 写了一个小东西。 可编译不通过 VC6 XPrnrnGOOGLE 了一下。 很多答案都是说定义类的时候 丢了最后一个 ;号rnrn我仔细的找了一下 发现没有丢; 号rnrn 可以我的提示错误行 却在 构造函数 对 对象成员的初始化这。 令我百思不得其解。rnrn请各位大大 指出错误。rnrn先谢谢了rnrnscore.cpprn[code=C/C++]#include rnrnclass Score rn float computer;rn float english;rn float mathematics;rnpublic:rn Score(float x1,float y1,float z1);rn Score();rn void print();rn void modify(float x2,float y2,float z2);rn;rnScore::Score(float x1,float y1,float z1)rnrn computer = x1;english = y1;mathematics = z1;rnrnScore::Score()rnrn computer = 0;english = 0;mathematics=0;rnrnvoid Score::modify(float x2,float y2,float z2)rnrn computer = x2 ;english = y2 ; mathematics = z2;rnrnvoid Score::print()rnrn cout<<"\nscore of computer:"<rn#include rn#include "score.cpp"rnrnclass Student rnprivate:rn int number;rn char* name;rn Score aScore; //Score 成员对象rnpublic:rn Student(int number1,char* name,float score1,float score2,float scroe3);rn ~Student();rn //把MODIFY 也扩充为整个对象的修改rn void modify(int number2,char* name2,float score21,float score22,float score23);rn void print();rnrnStudent::Student(int number1,char* name1,float score1,float score2,float score3) rn:aScore(score1,score2,score3)//对象成员aScore初始化rnrn number = number1;rn name = new char[strlen(name1)+1];rn strcpy(name,name1);rnrnStudent::~Student()delete name;rnvoid Student::modify(int number2,char* name2,float score21,float score22,float score23)rnrn number = number2;rn name = name2;rn aScore.modify(score21,score22,score,23);//修改对象成员rnrnvoid Student::print()rnrn cout<<"\number:"<> numberi;rn cout<<"name:";rn cin>>namei;rn cout<<"score of computer:";rn cin>>score1;rn cout<<"score of english:";rn cin>>score2;rn cout<<"score of mathematics:";rn cin>>score3;rn Student aStudent(numberi,namei,score1+1,score2+1,score3+1);rn aStudent.print();rn aStudent.modify(numberi,namei,score1+1,score2+1,score3+1);rn aStudent.print();rn delete namei;rn return 0;rnrn[/code]
A question about using GDI+
我设置好了环境已经能使用GDI+了,可是为甚么下面这样一个简单的语句,居然会出现那么多的错误,大家指点一下.rnImage *pImage=Image::FromStream(pStream,FALSE);rnrnError:rnD:\MyWorkspace\Project\JoyousPage\JPImage.cpp(64) : error C2065: 'Image' : undeclared identifierrnD:\MyWorkspace\Project\JoyousPage\JPImage.cpp(64) : error C2065: 'pImage' : undeclared identifierrnD:\MyWorkspace\Project\JoyousPage\JPImage.cpp(64) : error C2653: 'Image' : is not a class or namespace namernD:\MyWorkspace\Project\JoyousPage\JPImage.cpp(64) : error C2065: 'FromStream' : undeclared identifierrnD:\MyWorkspace\Project\JoyousPage\JPImage.cpp(64) : error C2106: '=' : left operand must be l-value
Using a Microprocessor to Configure Xilinx
是一个利用ARM配置FPGA的方法,包括从串模式,和从并模式
Find the process using a Dll ?
I try to Un-register VFP6RENU.DLL, but get the error "DllUnregisterServer may not be exported, or a corrupt version of VFP6RENU.DLL may be in memory. Consider using PView to detect and remove it".rnrnI have Process Viewer in MSVS 6.0, but I didn't find how to get the process which is using that Dll. If someone knows, please help.rn
Using a TopComponent's Lookup
NetBeans Selection Management Tutorial I—Using a TopComponent's Lookup
Using a GUI in an Embedded System
Using a GUI in an Embedded System
Using the StateRover© to Develop Controllers for A
NULL 博文链接:https://eric2007.iteye.com/blog/348874
IPSec Acceleration Using a Programmable.pdf
Efficient Software Architecture for IPSec Acceleration Using a Programmable Security Processor
A Brief Guide to Using NetDraw
NetDraw,复杂网络分析软件,这是它的使用说明书
这个报错如何解决?
在windows的OPEN事件里,rndw_1.settransobject(sqlca)rndw_1.retrieve()rnrn一运行,就会出现下面的报错:rn Database transaction information not available.Call SetTrans or SetTransObject function.rnrn报错之后会正常显示数据。请问这个是怎么回事?rnrn
A DTSA Protocol using on VANET
This paper proposes a DTSA Detection Technique against a Sybil Attack protocol so that it can provide vehicles with the secure information for the road situation and the traffic flow among vehicles and by detecting a Sybil attack
Discrete Mathematics Using a Computer
一本不错的离散数学教程<br>前几天看高教出版社的离散数学教程,很多问题越看越糊涂<br>于是上网搜到了这本书,发现讲得又清楚又明白<br>——可笑的是,在这本书里看明白的问题,再回到高都出版社的那本离散数学,又看不明白啦,所以那本书现在已经变成灰了。<br>P.S.烧书是一件很艰苦的事情,建议住单元房里的TX不要学我去尝试了
Using htmlText in a toolTip in flex
NULL 博文链接:https://hb0504511129-126-com.iteye.com/blog/1343849
如何解决这个报错
页面时常弹出以下错误提示,请问如何解决?rn"0x0292cf8d"指令引用"0x0292cf8d"内存.该内存不能为"read".要终止程序,请单击"确定"
[Error] a function-definition is not allowed here before '' token
[b]void main()下面一行出现这样的错误[Error] a function-definition is not allowed here before '' tokenrn 还有最后一行出现这样的错误[Error] expected '' at end of input[/b]rn[b]用vc6的cpp文件[/b]rn[b]是一个非常非常新手,请大家多包容。这个文件是弄一个线性表顺序结构和链式表顺序结构的实现。rn[/b]rnrn#include"stdio.h"rn#include"stdlib.h"rn#define ERROR 0rn#define OK 1rn#define OVERFLOW -2rn#define MAXSIZE 100rnrnrntypedef int Status;rntypedef int ElemType;rnrntypedef structrn ElemType *elem;rn int length;rnSqList;rnrntypedef struct LNodernrn ElemType data; //结点的数据域 rn struct LNode *next; //结点的指针域 rnLNode,*LinkList; //LinkList为指向结构体LNodede的指针类型 rnrnrnStatus Initlist(SqList *L);//初始化rnint getlength(SqList L);//取长度rnStatus GetElem(SqList L,int i,ElemType *e);//取值rnint LocateElem(SqList L,ElemType e);//查找rnStatus ListInsert(SqList *L,int i, ElemType e);//插入rnStatus ListDelete(SqList *L,int i);//删除rnrnStatus InitList(LinkList &L);//初始化 rnint Getlength(LinkList L);//取长度 rnStatus getElem(LinkList L,int i,ElemType &e);//取值 rnLNode *LocateElem(LinkList L,ElemType e);//查找 rnStatus listInsert(LinkList &L,int i,ElemType e);//插入 rnStatus listDelete(LinkList &L,int i);//删除 rnrnrnrnStatus Initlist(SqList *L)//初始化rnrnL->elem=new ElemType[MAXSIZE];rnif(!L->elem) exit(OVERFLOW);rnL->length=0;rnreturn OK;rnrnrnint getlength(SqList l)//取长度rn return l.length;rnrnrnrnStatus GetElem(SqList L,int i,ElemType *e)//取值rnif(i<1||i>L.length) return ERROR;rn*e=L.elem[i-1];rnreturn OK;rnrnrnrnint LocateElem(SqList L,ElemType e)//查找rnint i;rn for(i=0;iL->length+1)) return ERROR;rnif(L->length==MAXSIZE) return ERROR;rnfor(j=L->length-1;j>=i-1;j--)rn L->elem[j+1]=L->elem[j];rnL->elem[i-1]=e;rn++L->length;rnreturn OK;rnrnrnrnStatus ListDelete(SqList *L,int i)//删除rnrnint j;rnif((i<1)||(i>L->length)) return ERROR;rnfor(j=i;j<=L->length-1;j++)rn L->elem[j-1]=L->elem[j];rn--L->length;rnreturn OK;rnrnrnStatus InitList(LinkList &L)rn//构造一个空的单链表L rn L=new LNode;//生成新结点作为头结点,用头指针L指向头结点 rn L->next=NULL;//头结点的指针置空 rn return OK;rnrnrnint Getlength(LinkList L)rnint num=0;rn LNode *p;rnp=L->next;rnwhile(p!=NULL)rnnum++;rnp=p->next;rnrnreturn(num);rnrnrnStatus getElem(LinkList L,int i,ElemType &e)rnLNode *p;rn p=L->next;int j=1;rn while(p&&jnext;rn ++j;rn rn if(!p||j>i) return ERROR;rn e=p->data;rn return OK;rn rnrnLNode *LocateElem(LinkList L,ElemType e)rnLNode *p;int k=1;rn p=L->next;rn while(p&&p->data!=e)rn p=p->next;rn ++k;rn rn return p;rnrnrnStatus listInsert(LinkList &L,int i,ElemType e)rnLNode *p;LNode *s;rnp=L;int j=0;rnwhile(p&&(jnext;++j;//查找第i-1个结点,p指向该结点rnif(!p||j>i-1) return ERROR; //i>n+1rn s=new LNode;rn s->data=e;rn s->next=p->next;rn p->next=s;rn return OK;rn rnrnStatus listDelete(LinkList &L,int i)rn LNode *p;LNode *q;rnp=L;int j=0;rnwhile((p->next)&&(jnext;++j;rnif(!(p->next)||(j>i-1)) return ERROR;rnq=p->next;rnp->next=q->next;rndelete q;rnreturn OK;rnrnrnrnvoid j1();rnvoid j2();rnrnvoid main()rnint x;rnsystem("cls");rnprintf("\t\t\t\t\t\t\t\t\t\t\t主菜单\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t1.顺序表\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t2.链表\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t3.退出\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t输入选项(输入1~3中数字):");rnscanf("%d",&x);rnif(x==3) break;rnswitch(x)rncase 1:j1();break;rncase 2:j2();break;rnrnrnreturn 0;rnrnrnrnrnvoid j1()rnint a;rnrnSqList L;int x;Status t;int i,j;ElemType e;int len;rnrnwhile(1)rnsystem("cls");rnprintf("\t\t\t\t\t\t\t\t\t\t\t1.初始化线性表\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t2.求线性表的长度\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t3.按序号取元素\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t4.按值查找\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t5.插入元素\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t6.删除元素\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t7.返回\n");rnprintf("\t\t\t\t\t\t\t\t\t\t\t输入选项(输入1~7中数字):");rnscanf("%d",&a);rnif(a==7)break;rnrnswitch(a)rncase 1:t=Initlist(&L);rnif(t==OK) printf("初始化成功");rnelse printf("初始化失败");rnsystem("pause");break;rncase 2:len=getlength(L);rn printf("\t\t\t\t\t\t\t\t\t\t\t线性表的长度为%d\n",len);rnsystem("pause");break;rncase 3:printf("\t\t\t\t\t\t\t\t\t\t\t请输入你要取数的序号:");rnscanf("%d",&i);rnt=GetElem(L,i,e);rn if(t==OK)printf("\t\t\t\t\t\t\t\t\t\t\t您所取的元素是:%d\n",e);rnelse printf("取值失败");rnsystem("pause");break;rncase 4:printf("\t\t\t\t\t\t\t\t\t\t\t请输入你要查找的值");rnscanf("%d",&i);rnt=LocateElem(L,e);rnif(t==0)printf("\t\t\t\t\t\t\t\t\t\t\t查找失败");rnelse printf("\t\t\t\t\t\t\t\t\t\t\t您查找的元素序号为:%d\n",t);system("pause");break;rncase 5:printf("\t\t\t\t\t\t\t\t\t\t\t请输入你要插入的位置");scanf("%d",&i);rnprintf("\t\t\t\t\t\t\t\t\t\t\t请输入你要插入的数值");scanf("%d",&e);rnt= ListInsert (&L,i,e);rn if(t==OK)printf("插入成功");else printf("插入失败");system("pause");break;rncase 6:printf("请输入你要删除的数的位置");scanf("%d",&i);rnt=ListDelete(&L,i);rn if(t==OK)printf("删除成功");else printf("删除失败");system("pause");break;rnrnrnrnrnrnvoid j2()rn int b;LinkList L;int x;Status t;int i,j;ElemType e;int len;LNode *m;int k;rn while(1) rn system("cls");rn printf("\t\t\t\t\t\t\t\t\t\t\t\t\t1:初始化线性表\n");rn printf("\t\t\t\t\t\t\t\t\t\t\t\t\t2:求线性表的长度\n");rn printf("\t\t\t\t\t\t\t\t\t\t\t\t\t3:按序号取元素\n");rn printf("\t\t\t\t\t\t\t\t\t\t\t\t\t4:按值查找\n");rn printf("\t\t\t\t\t\t\t\t\t\t\t\t\t5:插入元素\n");rn printf("\t\t\t\t\t\t\t\t\t\t\t\t\t6:删除元素\n");rn printf("\t\t\t\t\t\t\t\t\t\t\t\t\t7:返回\n");rn printf("\t\t\t\t\t\t\t\t\t\t\t\t\t请输入你的选择(在1-7中选择):");rn scanf("%d",&b);rn if(b==7) break;rn switch(b)rncase 1:t=InitList(&L);rnif(t==OK) printf("初始化成功");rnelse printf("初始化失败");system("pause");break;rncase 2:len=Getlength(L);rn printf("\t\t\t\t\t\t\t\t\t\t\t线性表的长度为%d\n",len);system("pause");break;rncase 3:printf("\t\t\t\t\t\t\t\t\t\t\t请输入你要取数的序号:");rnscanf("%d",&i);rnt=getElem(L,i,e);rn if(t==OK)printf("\t\t\t\t\t\t\t\t\t\t\t您所取的元素是:%d\n",e);rnelse printf("取值失败");system("pause");break;rncase 4:printf("\t\t\t\t\t\t\t\t\t\t\t请输入你要查找的值");rnscanf("%d",&i);rnm=LocateElem(L,e);rnif(m==0)printf("\t\t\t\t\t\t\t\t\t\t\t查找失败");rnelse printf("\t\t\t\t\t\t\t\t\t\t\t您查找的元素序号为:%d\n",k);system("pause");break;rncase 5:printf("\t\t\t\t\t\t\t\t\t\t\t请输入你要插入的位置");scanf("%d",&i);rnprintf("\t\t\t\t\t\t\t\t\t\t\t请输入你要插入的数值");scanf("%d",&e);rnt=listInsert(&L, i,e);rn if(t==OK)printf("插入成功");else printf("插入失败");system("pause");break;rncase 6:printf("请输入你要删除的数的位置");scanf("%d",&i);rnt=listDelete(&L,i);rn if(t==OK)printf("删除成功");else printf("删除失败");system("pause");break;rnrn rn
编译提示:constructors not allowed a return type
最近在看thinking in c++书,用VC++调试时遇到如下问题,rnstringstack::stringstack():index(0)rnrn memset(stack,0,size*sizeof(char*));rnrnrn调试结果显示:'stringstack::stringstack' : constructors not allowed a return typern如何修改? 谢谢!
the server responded with a status of 405 (Method Not Allowed)
这个是我ajax的调用方法rn[code=javascript]rn$.ajax(rn type: "post",rn url: "/m/Ajax/AjaxAppOrWeChat.ashx?method=DisposeData",rn data: "strData": str ,rn success: function(data) rn if (data == "")rn alert("数据丢失!");rn else rn empID = data.split(",");rn app = empID[1];rn empID = empID[0];rn dataload();rn rn rn )rn[/code]rnrn在我本地测试的时候是没有任何问题的 但是一放到服务器上面 就会报the server responded with a status of 405 (Method Not Allowed)这个错 请问各位大神 这是什么情况
Operation not allowed on a unidirectional dataset怎么办?
我用BCB6.0用dbExpress连接远程mysql时rn在DBGird中设置DataSource时,弹出这个对话框!rnrn请各位大虾帮忙!rn小弟接触BCB时间不长!英文也不好!rn
create table a(a clob);为什么报错?
SQL> create table a(a clob);rncreate table a(a clob)rn *rn错误位于第1行:rnORA-22866: 默认字符集具有不同的宽度
这个该如何解决?
有这样一段XMLrn[code=XML]rnrn rn rn 11111rn rn 1rn rn rn 22222rn rn 2rn rn rn 33333rn rn 3rn rn rn rn rn 11111rn rn 1rn rn rnrnrn[/code]rn我想修改所有的标签中的值,的个数不确定rn 的个数也不确定rnrnrnrnrn
相关热词 c#异步发送kafka c#窗体编号 c# 操作二进制文件 c# 反射 机制 c#线程 窗体失去响应 c#角度转弧度 c# 解析gps数据 c# vs设置 语法版本 c# json含回车 c#多线程demo

相似问题

5
Tensorflow object-detection api 报错
0
tensorflow的InvalidArgumentError报错问题(placeholder)
1
基于tensorflow的pix2pix代码中如何做到输入图像和输出图像分辨率不一致
1
图片数据集的写入和读取 tfrecord, tfdata
1
深度学习图片识别循环停止?
1
tensorflow-gpu Failed to get convolution algorithm.
1
pyqt5中如何通过OpenCV读取一帧图像喂入网络呢?
1
我的py文件可以在python3.6.2上运行,但是却不能在终端上运行,不知道问题出在哪,请求大佬帮帮忙,谢谢。
1
ValueError: None values not supported.
1
tf.train.shuffle_batch要求定义张量的shape,Tensor不定长时如何使用shuffle_batch
0
tensorflow多维素组改变特定元素值报错
1
想把两个13维数组合并成一个26维数组,用np.append之后报错,用extend和append好像也不行,为什么?
0
如何对使用ssd检测出来的目标进行计数
1
Tensorflow object detection API 使用VOC数据集出现错误。
1
tensorflow重载模型继续训练得到的loss比原模型继续训练得到的loss大,是什么原因??
1
如何解决tensorflow中的图片维度转换问题?
0
不加阈值可以正常运行,当我想在输出层增加一个阈值判断,但是疯狂报错了,如何解决?
2
用TensorFlow 训练mask rcnn时,总是在执行训练语句时报错,进行不下去了,求大神
0
树莓派命令行中调用找不到dark flow,但打开python环境后单独运行dark flow就没问题,为什么?
1
修改的SSD—Tensorflow 版本在训练的时候遇到loss输入维度不一致