#include<iostreamh>
#include<stdlibh>
const int maxsize=100;//最大元素个数
typedef char Datatype;
class seqstack
{
int top;
Datatype s;
public:
seqstack();//构造函数
~seqstack();//析构函数
void push(Datatype x);
void match(char k);
};
seqstack temp;
seqstack::seqstack()
{
top=0;
s=new Datatype[maxsize];
}
seqstack::~seqstack()
{
delete []s;
}
void seqstack::push(Datatype x)
{
if(top==maxsize)
{
cout<<"栈满"<<endl;
exit(0);
}
else
{
s[top]=x;
}
}
bool ma(char a,char b)
{
if((a=='('&&b==')')||(a=='['&&b==']')||(a=='{'&&b=='}'))
return true;
else
return false;
}
void seqstack::match(char k)
{
int u,v;
for(int i=0;k[i]!='\0';i++)
{
if(k[i]=='('||')'||'['||']'||'{'||'}')
{
temppush(k[i]);
top++;
}
}
if(top%2==1)
{
cout<<"括号多余"<<endl;
}
else
{
u=top/2;
v=u+1;
while(u!=-1)
{
if(ma(s[u],s[v]))
{
u--;
v++;
}
else
{
cout<<"括号不匹配"<<endl;
break;
}
}
if(u==-1)
cout<<"左右括号匹配正确"<<endl;
}
}
void main()
{
char p[10];
cout<<"请输入一个含括号的字符串"<<endl;
cin>>p;
tempmatch(p);
} 只是修改编译错误吗? 我改好了 ,还修改了个死循环 ,你少了一边大括号,还有case那加上了break
首先看size(vv,2)
参考网页链接
size(vv, 2)表示取矩阵vv的列数。如果vv是多维矩阵,则表示的仍然是取每个二维矩阵的列数。
举例说明如下:
% 如果vv是2维矩阵(行向量或列向量可看为行数或列数为1的矩阵)vv=[1, 2, 3; 4, 2, 3];
col = size(vv, 2); % 计算结果为col=3,因为矩阵vv的列数为3
% 如果vv是多维矩阵(以3维矩阵为例)
vv(:, :, 1)=[1, 2, 3; 4, 2, 3];
vv(:, :, 2)=[4, 2, 2; 6, 2, 4];
col = size(vv, 2); % col的值仍然为3,因为三维矩阵vv的每个2维矩阵都有3列
现在我们假定col=size(vv, 2)
for i=1:size(vv,2) %循环 *** 作,把i从1加到col,每+1,执行下列代码一次if(dd(i,i)>1e-4) %若矩阵dd第i行,第i列对应的值大于10的-4次方,执行下列代码
v=[v vv(:,i)]; % 矩阵v=原矩阵v右边加上矩阵vv的第i列
d=[d dd(i,i)]; % 矩阵d=原矩阵d右边加上矩阵d的第i行,第i列对应的元素
在unity中画抛物线的方法,代码如下:
抛物线公式y=axx+bx+c;a>0,开口向上;
a<0,开口向下。b=0,抛物线对称轴为y轴。c=0,抛物线经过原点。
获取一些抛物线上的点,然后相邻的两点和原点画三角面,这样可以用三角面拼成了“抛物面”了,
而且还可以通过修改a的值来改变小山峰的陡峭程度。
直接晒代码 Parabolajs :
private var a:int;//a>0,开口向上;a<0,开口向下。
private var b:int;//b=0,抛物线对称轴为y轴
private var c:int;//c=0,抛物线经过原点
private var size:int;
function Start () {
a=-1;
b=0;
c=0;
size=22;
gameObjectAddComponent("MeshFilter");
gameObjectAddComponent("MeshRenderer");
var mesh : Mesh = GetComponent(MeshFilter)mesh;
meshClear();
var v:Vector3[]=new Vector3[size];
var v2:Vector2[]=new Vector2[size];
var index:int []=new int[(size-2)3];
for(var i:int=0;i
if(i==0)
{
v[i]=Vector3(0,-1,0);
}
else
{
var x:float=(i-size/2)01;
v[i]x=x;
v[i]y=axx+bx+c;
v[i]z=0;
}
if(i>1){
index[3i-6]=0;
index[3i-5]=i-1;
index[3i-4]=i;
}
print("v["+i+"]="+v[i]);
}
meshvertices = v;
meshuv = v2;
meshtriangles = index;
for(var j:int=0;j
print(j+"=="+index[j]);
}
}
ASP本身不能实现该功能,但是可以用具有读写二进制文件功能的AdodbStream对象来间接实现
<%
'下面这段即可获得你要的那的宽和高
imgpath="images/photo/abcjpg"
set pp=new imgInfo
w = ppimgW(servermappath(imgpath))
h = ppimgH(servermappath(imgpath))
set pp=nothing
%>
<%
'这一段是所要用的类
Class imgInfo
dim aso
Private Sub Class_Initialize
set aso=CreateObject("AdodbStream")
asoMode=3
asoType=1
asoOpen
End Sub
Private Sub Class_Terminate
errclear
set aso=nothing
End Sub
Private Function Bin2Str(Bin)
Dim I, Str
For I=1 to LenB(Bin)
clow=MidB(Bin,I,1)
if ASCB(clow)<128 then
Str = Str & Chr(ASCB(clow))
else
I=I+1
if I <= LenB(Bin) then Str = Str & Chr(ASCW(MidB(Bin,I,1)&clow))
end if
Next
Bin2Str = Str
End Function
Private Function Num2Str(num,base,lens)
dim ret
ret = ""
while(num>=base)
ret = (num mod base) & ret
num = (num - num mod base)/base
wend
Num2Str = right(string(lens,"0") & num & ret,lens)
End Function
Private Function Str2Num(str,base)
dim ret
ret = 0
for i=1 to len(str)
ret = ret base + cint(mid(str,i,1))
next
Str2Num=ret
End Function
Private Function BinVal(bin)
dim ret
ret = 0
for i = lenb(bin) to 1 step -1
ret = ret 256 + ascb(midb(bin,i,1))
next
BinVal=ret
End Function
Private Function BinVal2(bin)
dim ret
ret = 0
for i = 1 to lenb(bin)
ret = ret 256 + ascb(midb(bin,i,1))
next
BinVal2=ret
End Function
Private Function getImageSize(filespec)
dim ret(3)
asoLoadFromFile(filespec)
bFlag=asoread(3)
select case hex(binVal(bFlag))
case "4E5089":
asoread(15)
ret(0)="PNG"
ret(1)=BinVal2(asoread(2))
asoread(2)
ret(2)=BinVal2(asoread(2))
case "464947":
asoread(3)
ret(0)="GIF"
ret(1)=BinVal(asoread(2))
ret(2)=BinVal(asoread(2))
case "535746":
asoread(5)
binData=asoRead(1)
sConv=Num2Str(ascb(binData),2 ,8)
nBits=Str2Num(left(sConv,5),2)
sConv=mid(sConv,6)
while(len(sConv)<nBits4)
binData=asoRead(1)
sConv=sConv&Num2Str(ascb(binData),2 ,8)
wend
ret(0)="SWF"
ret(1)=int(abs(Str2Num(mid(sConv,1nBits+1,nBits),2)-Str2Num(mid(sConv,0nBits+1,nBits),2))/20)
ret(2)=int(abs(Str2Num(mid(sConv,3nBits+1,nBits),2)-Str2Num(mid(sConv,2nBits+1,nBits),2))/20)
case "FFD8FF":
do
d p1=binVal(asoRead(1)): loop while p1=255 and not asoEOS
if p1>191 and p1<196 then exit do else asoread(binval2(asoRead(2))-2)
dp1=binVal(asoRead(1)):loop while p1<255 and not asoEOS
loop while true
asoRead(3)
ret(0)="JPG"
ret(2)=binval2(asoRead(2))
ret(1)=binval2(asoRead(2))
case else:
if left(Bin2Str(bFlag),2)="BM" then
asoRead(15)
ret(0)="BMP"
ret(1)=binval(asoRead(4))
ret(2)=binval(asoRead(4))
else
ret(0)=""
end if
end select
ret(3)="width=""" & ret(1) &""" height=""" & ret(2) &""""
getimagesize=ret
End Function
Public Function imgW(pic_path)
Set fso1 = serverCreateObject("ScriptingFileSystemObject")
If (fso1FileExists(pic_path)) Then
Set f1 = fso1GetFile(pic_path)
ext=fso1GetExtensionName(pic_path)
select case ext
case "gif","bmp","jpg","png":
arr=getImageSize(f1path)
imgW = arr(1)
end select
Set f1=nothing
else
imgW = 0
End if
Set fso1=nothing
End Function
Public Function imgH(pic_path)
Set fso1 = serverCreateObject("ScriptingFileSystemObject")
If (fso1FileExists(pic_path)) Then
Set f1 = fso1GetFile(pic_path)
ext=fso1GetExtensionName(pic_path)
select case ext
case "gif","bmp","jpg","png":
arr=getImageSize(f1path)
imgH = arr(2)
end select
Set f1=nothing
else
imgH = 0
End if
Set fso1=nothing
End Function
End Class
%>
以上就是关于c++ 找错误 (括号匹配问题)全部的内容,包括:c++ 找错误 (括号匹配问题)、matlab中 for i=1:size(S,2) 什么意思、如何在Unity中画unity 抛物线运动等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)