0;在编写输入一个整数,然后调用oushu

来源:百度知道 编辑:UC知道 时间:2024/06/20 02:02:02
马上,在考试,谢谢1 编写一个函数oushu(),判断给定的整数是否是偶数,如果是偶数,则返回1,否则返回0;在编写一个主函数,主函数从键盘输入一个整数,然后调用oushu()函数,并根据返回值输出判断结果

2 从键盘输入字符窜str,字符ch为你的名字汉语拼音的尾字母,例如:你的名字汉语拼音为lidongze,则ch为‘e’,输出字符ch在字符串str中出现的次数

第一题:
Private Function oushu(ByVal x As Integer)
flag = 1
If x Mod 2 = 0 Then flag = 0
If flag = 0 Then Print i & "这个数是偶数!"
If flag = 1 Then Print i & "这个数是奇数!"

End Function
Private Sub Command1_Click()
i = InputBox("请输入一个数:")
Call oushu(i)
End Sub

第二题:
n=0
i=inputbox("请输入一个字符窜:")
for j=1 to len(i)
if mid(str,j,1)="e" then s=s+1
next j

//problem 1
#include <stdio.h>
#include <stdlib.h>

int oushu(int n)
{
return n % 2 == 0 ? 1 : 0;
}

int main()
{
int n;
printf("请输入n:\n");
scanf("%d",&n);
if(oushu(n))
printf("%d是偶数\n",n);
else
printf("%d是奇数\n",n);
return 0;
}

//problem2
#include <stdio.h>
#include <stdlib.h>

int calc(char c,ch