程序题:输出给出数值的奇偶属性
来源:百度知道 编辑:UC知道 时间:2024/05/26 12:42:58
题目详细:程序题:输出给出数值的奇偶属性,如果是奇数就输出“奇数”,否则输出偶数
能不能把答案同时再解释一下啊?
是ASP的
能不能把答案同时再解释一下啊?
是ASP的
temp=shu-(int)(shu/2)*2
if temp=1 then response.write "奇数"
else
if shu-(int)(shu/2)*2=0 then response.write "偶数"
else response.write "不是整数"
end if
end if
boolean(int x)
{
int i;
i=x%2;
if(i)
printf("true");
else
printf("false");
}
说明:这是一个构造函数,在主函数里调用函数 boolean()就行了,例:boolean(t);t是你需要判断的数
c++编写的.你看适合吗.
int main()
{
int y=0;
cout <<"please input the number"<<endl;
cin >> y;
if!(y%2)
cout<<"this is oushu"<<endl;
cout<<"this is jishu"<<endl;
else
cout<<"input the oushu and jishu"<<endl;
}
ASP
完整的代码(将此文件命为num.asp)
<%
num=request("num")
%>
<script language = "VBScript">
function validate_myfo