[汇编语言程序设计]1、用减奇数法开平方。(算法:N个自然数中的奇数之和等于N的平方。) 程序清单:内存datum中存要开方数 ,result中存放结果 data segment datum db 16 result db 0 data ends ss_seg...+阅读
#include
int primeNum(int p)
{
int i, q;
/* Negative number is not a prime */
if (p < 0)
return 0;
q = (int) sqrt(p);
for (i = 2; i < q; i++)
if ((p % i) == 0)
return 0;
/* No factor of p is found */
return 1;
}
/*原理::
从2-sqrt(x)的数中看是否有可以整除的, 如果没有, 则为素数.
*/
延伸阅读:
汇编语言程序设计红旗慢慢升起code segment assume cs:code start: push cs pop ds mov ax,12h int 10h mov ax,0a000h mov es,ax mov ah,2;画旗杆 call color mov di,510 mov ax,0aeh mov cx,450 n1:stos...
VB选择循环和数组综合程序设计实验报告Private Sub Form_Click() Dim r(1 To 60) As Integer Dim e(1 To 60) As Integer Dim o(1 To 60) As Integer Dim ec As Integer, oc As Integer Dim i As Integer, j As I...
求大神帮忙做一下这个大学VB程序设计的实验报告Private Sub Command1_Click() Dim a As Integer, b As String, i As Integer, c() As String a = Len(Text1.Text) Print a ReDim c(a) As String For i = 1 To a b = Mid(...
VB程序设计实验报告1.实验名称 实验二 Visual Basic基本语句 2.实验目的 (1)掌握Visual Basic的数据类型和变量定义方法。 (2)正确使用Visual Basic的运算符和表达式。 (3)掌握Visual Basic中...
VB程序设计实验报告过程与函数求高手出手急用的我要'计算两个数的和和积 Option Explicit Dim x As Double Dim y As Double Private Sub Cmd1_Click() x = InputBox("请输入一个数:", , 0#) y = InputBox("请再输入一个数:", , 0#) Text1.T...
vb实验题程序设计dim iMax as Single,iMin as Single,iSum as Single dim i as integer private sub Command1_click() iSum=0 for i=0 to 9 isum=isum+val(text1(i).text) if iMax<val(text...
程序设计VB实验Option Explicit Function Prime(N As Integer) As Boolean Dim I As Integer If N < 2 Then Prime = False: Exit Function For I = 2 To N - 1 If N Mod I = 0 Then Prime...
java面向对象程序设计实验报告怎么写1。People.javapublic class People { //性别(sex)及出生日期(date);方法成员有:获取人的性别和出生日期及构造方法。要求构造方法可以设置性别和出生日期的初始值。 private int...
C语言程序设计课程实验报告#incude <stdio.h> int main() { int en_num=0,ma_num=0,blank_num,other_num; char ch; while((ch=getchar()) != '#'){ if(ch>='0' & ch<='9') ma_num++; else if((ch>='a...