稀疏矩阵的转置

采用二元数组存储,转置较简单

利用2个for循环,互换i和j的值(m,n控制数组的大小)

如下

[cce_cpp]
int i,j;

for(i=0;i<m;i++)

     for(j=0;j<n;j++)

       d[i][j]=s[j][i];
[/cce_cpp]

关于矩阵采用三元组表存储,需要:

1.讲矩阵的行列值互相交换。

2.讲三元组的i和j互换。

3.重排三元组的顺序。

关于3的具体实现

[cce_cpp]
#include <stdio.h>
#include <malloc.h>
#define Max 100
#define FALSE 0
typedef struct
{
int val;
int row,col;
}Triple;

typedef struct
{
Triple data[Max];
int m,n,len;
}TSMatrix;

TSMatrix *FastTransposeTSMatrix(TSMatrix a,TSMatrix *b)
{
int col,t,i,j;
int num[Max],cpot[Max];
b->len=a.len;b->n=a.m,b->m=a.n;
if(b->len)
{
   for(col=1;col<=a.n;col++)
    num[col]=0;
   for(t=1;t<=a.len;t++)
    num[a.data[t].col]++;
   cpot[1]=1;
   for(col=2;col<a.n;col++)
    cpot[col]=cpot[col-1]+num[col-1];
   for(i=1;i<=a.len;i++)
   {
    col=a.data[i].col;j=cpot[col];
    b->data[j].row=a.data[i].col;
     b->data[j].col=a.data[i].row;
      b->data[j].val=a.data[i].val;
      cpot[col]++;
   }
}
return(b);
}
main()
{
TSMatrix A,*B;
B=(TSMatrix *)malloc(sizeof(TSMatrix));
int i;
A.len=5;A.m=5;A.n=5;
printf("input TSMatrix a:\n");
for(i=1;i<=5;i++)
   scanf("%d,%d,%d",&A.data[i].row,&A.data[i].col,&A.data[i].val);
B=FastTransposeTSMatrix(A,B);
printf("The Transpose TSMatrix is:\n");
for(i=1;i<=5;i++)
   printf("%d,%d,%d\n",B->data[i].row,B->data[i].col,B->data[i].val);
}
[/cce_cpp]

实现后如下

稀疏矩阵的转置
稀疏矩阵的转置

asp简单的转向

通过3.asp来登陆,然后利用check.asp来检查,保存公用变量,分别转向管理员和普通用户
[cce_html]
3.asp

<%language="vbscript"%>
<html>
<head>
<title>登陆验证</title>
</head>
<body>
<p align="center" ><font color=red>登陆验证</font></p>
<form name="bd" method="post" action="check.asp">
<table width="100%" border="0" cellpadding="0" cellspacing="">
<tr><td width="50%" align="right" valign="middle" height="37"><font color=red>*</font>用户名:</td>
<td width="50%" align="left" valign="middle" height="37"><input type="text" name="yh" size="17"></td></tr>
<tr><td width="50%" align="right" valign="middle" ><font color=red>*</font>密码:</td>
<td width="50%" align="left" valign="middle"><input type="password" name="mm" size="18"></td></tr>
<tr><td align="right"><input type="submit" name="tj" value="提交"></td>
<td align="left"><input type="Reset" name="qx" value="取消"></td></tr>
</table>
</form>
</body>
</html>

check.asp

<%language="vbscript"%>
<%response.buffer=true%>
<html>
<head>
</head>
<title>登陆验证</title>
<body>
<% session("user")=request.form("yh")
   session("password")=request.form("mm")
if session("user")="admin" and session("password")="admin" then
Response.clear
Response.Redirect "admin.asp"
else
Response.Redirect "user.asp"
end if
%>
</body>
</html>

admin.asp

<%language="vbscript"%>
<html>
<head>
</head>
<title>登陆验证</title>
<body>
<%
Response.Write "欢迎管理员:"&session("user")&"你是管理员用户,可以进行添加,删除,修改,查询操作!"&"<br>"
%>
</body>
</html>

user.asp

<%language="vbscript"%>
<html>
<head>
</head>
<title>登陆验证</title>
<body>
<%
Response.Write "欢迎用户:"&session("user")&"你是一般用户,可以查询,修改自己信息的操作!"&"<br>"
%>
</body>
</html>
[/cce_html]

asp的QUERYSTRING使用

利用的参数来传递值

利用QUERYSTRING来接收

例子在下面

[cce_html]
2.htm

<html>
<head></head>
<title></title>
<body>
<center><a href="修改后的2.asp?name=admin">点击</a>
</body>
<html>

2.asp

<html>
<head>
</head>
<title>querystring获取数据</title>
<body>
<% Dim a
a=request.querystring("name")
Response.Write "你好:"&a&"<br>"
%>
</body>
</html>
[/cce_html]

asp实现Post方法提交数据

post方法主要用于大量数据传输,单独发送数据包传递

主要利用Request.form(“表单对象名称”)来接受数据

2个实例在下面

[cce_html]
1_2.htm

<html>
<head>
<title>Post方法提交数据</title>
</head>
<body>
<p align="center" ><font color=red>Post方法提交数据</font></p>
<form name="bd" method="post" action="1_2.asp">
<table width="100%" border="0" cellpadding="0" cellspacing="">
<tr><td width="50%" align="right" valign="middle" height="37"><font color=red>*</font>用户名:</td>
<td width="50%" align="left" valign="middle" height="37"><input type="text" name="yh" size="17"></td></tr>
<tr><td width="50%" align="right" valign="middle" ><font color=red>*</font>密码:</td>
<td width="50%" align="left" valign="middle"><input type="password" name="mm" size="18"></td></tr>
<tr><td width="50%" align="right" valign="middle" ><font color=red>*</font>确认密码:</td>
<td width="50%" align="left" valign="middle"><input type="password" name="qm" size="18"></td></tr>
<tr><td width="50%" align="right" valign="middle" ><font color=red>*</font>姓名:</td>
<td width="50%" align="left" valign="middle"><input type="text" name="xm" size="17"></td></tr>
<tr><td width="50%" align="right" valign="middle" ><font color=red>*</font>职业:</td><td align="left" valign="middle"><select name="xl" size="1">
<option value="1">学生
<option value="2">工人
<option value="3">教师
<option value="4">工程师
</select></td>
<tr><td width="50%" align="right" valign="middle"><font color=red>*</font>E-mail地址:</td>
<td width="50%" align="left" valign="middle"><input type="text" name="em" size="17"></td></tr>
<tr><td width="50%" align="right" valign="middle"><font color=red>*</font>地址:</td>
<td width="50%" align="left" valign="middle"><input type="text" name="dz" size="17"></td></tr>
<tr><td width="50%" align="right" valign="middle"><font color=red>*</font>电话:</td>
<td width="50%" align="left" valign="middle"><input type="text" name="dh" size="17"></td></tr>
<tr><td align="right"><input type="SUBMIT" name="tj" value="提交"></td>
<td align="left"><input type="Reset" name="qx" value="取消"></td></tr>
</table
</form>
</body>
</html>

1_2.asp

<%language="vbscript"%>
<html>
<head>
</head>
<title>Post方法提交数据</title>
<body>
<% Dim a,b,c,d,e,f,g
a=Request.form("yh")
b=Request.form("mm")
c=Request.form("qm")
d=Request.form("xm")
e=Request.form("em")
f=Request.form("dz")
g=Request.form("dh")

Response.Write "用户名:"&a&"<br>"
Response.Write "密码:"&b&"<br>"
Response.Write "确认密码:"&c&"<br>"
Response.Write "姓名:"&d&"<br>"
Response.Write "职业:"&e&"<br>"
Response.Write "地址:"&f&"<br>"
Response.Write "电话:"&g&"<br>"
%>
</body>
</html>
[/cce_html]

asp实现GET方法提交数据

get方法主要用于少量数据传输

主要利用Request.querystring(“表单对象名称”)来接受数据

[cce_html]
1_1.htm:

<html>
<head>
<title>GET方法提交数据</title>
</head>
<body>
<p align="center" ><font color=red>GET方法提交数据</font></p>
<form name="bd" method="get" action="1_1.asp">
<table width="100%" border="0" cellpadding="0" cellspacing="">
<tr><td width="50%" align="right" valign="middle" height="37"><font color=red>*</font>用户名:</td>
<td width="50%" align="left" valign="middle" height="37"><input type="text" name="yh" size="17"></td></tr>
<tr><td width="50%" align="right" valign="middle" ><font color=red>*</font>密码:</td>
<td width="50%" align="left" valign="middle"><input type="password" name="mm" size="18"></td></tr>
<tr><td width="50%" align="right" valign="middle" ><font color=red>*</font>确认密码:</td>
<td width="50%" align="left" valign="middle"><input type="password" name="qm" size="18"></td></tr>
<tr><td width="50%" align="right" valign="middle" ><font color=red>*</font>姓名:</td>
<td width="50%" align="left" valign="middle"><input type="text" name="xm" size="17"></td></tr>
<tr><td width="50%" align="right" valign="middle" ><font color=red>*</font>职业:</td><td align="left" valign="middle"><select name="xl" size="1">
<option value="1">学生
<option value="2">工人
<option value="3">教师
<option value="4">工程师
</select></td>
<tr><td width="50%" align="right" valign="middle"><font color=red>*</font>E-mail地址:</td>
<td width="50%" align="left" valign="middle"><input type="text" name="em" size="17"></td></tr>
<tr><td width="50%" align="right" valign="middle"><font color=red>*</font>地址:</td>
<td width="50%" align="left" valign="middle"><input type="text" name="dz" size="17"></td></tr>
<tr><td width="50%" align="right" valign="middle"><font color=red>*</font>电话:</td>
<td width="50%" align="left" valign="middle"><input type="text" name="dh" size="17"></td></tr>
<tr><td align="right"><input type="submit" name="tj" value="提交"></td>
<td align="left"><input type="Reset" name="qx" value="取消"></td></tr>
</table>
</form>
</body>
</html>

1_1.asp

<%language="vbscript"%>
<html>
<head>
</head>
<title>GET方法提交数据</title>
<body>
<% Dim a,b,c,d,e,f,g
a=Request.querystring("yh")
b=Request.querystring("mm")
c=Request.querystring("qm")
d=Request.querystring("xm")
e=Request.querystring("em")
f=Request.querystring("dz")
g=Request.querystring("dh")

Response.Write "用户名:"&a&"<br>"
Response.Write "密码:"&b&"<br>"
Response.Write "确认密码:"&c&"<br>"
Response.Write "姓名:"&d&"<br>"
Response.Write "职业:"&e&"<br>"
Response.Write "地址:"&f&"<br>"
Response.Write "电话:"&g&"<br>"
%>
</body>
</html>
[/cce_html]