计算机算法的题Develop an algorithm which takes as input a single 9-digit integer representing a Social Insurance Numbers (SIN) and determines whether or not it is valid.The algorithm should output if the SIN is valid or not.The rules determini

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/10 14:52:15
计算机算法的题Develop an algorithm which takes as input a single 9-digit integer representing a Social Insurance Numbers (SIN) and determines whether or not it is valid.The algorithm should output if the SIN is valid or not.The rules determini

计算机算法的题Develop an algorithm which takes as input a single 9-digit integer representing a Social Insurance Numbers (SIN) and determines whether or not it is valid.The algorithm should output if the SIN is valid or not.The rules determini
计算机算法的题
Develop an algorithm which takes as input a single 9-digit integer representing a Social Insurance Numbers (SIN) and determines whether or not it is valid.The algorithm should output if the SIN is valid or not.The rules determining the validity of a SIN are best described in an example.Consider the number 620187252 as a possible SIN number.Positions specified below are read from right to left and counting starts from 1.
1.Multiply every even positioned digit by 2.
(2x2=4,1x2=2,7x2=14,5x2=10)
2.For each result from step 1 add all the digits from each result together.
(4+2+1+4+1+0 = 12)
3.Add the last 4 odd positioned digits of the SIN together.
(6+0+8+2 = 16)
Page 4 of 4
4.Add the results of steps 2 and 3 together.
(12+16 = 28)
5.Subtract the units digit of the total from step 4 from 10,unless the units digit is 0,in which case use it.
(10-8 = 2)
6.A SIN is valid if the digit from step 5 is the same as the least significant digit in the SIN and the most significant digit matches a used region digit according to the following list:
0 not used
1 Atlantic Provinces
2 Quebec
3 not used
4 Ontario
5 not used
6 Prairie Provinces
7 British Columbia
8 not used
9 not used
(in the example,the SIN is a valid number which was issued in the Prairie Provinces)

计算机算法的题Develop an algorithm which takes as input a single 9-digit integer representing a Social Insurance Numbers (SIN) and determines whether or not it is valid.The algorithm should output if the SIN is valid or not.The rules determini
#include
#include
#include
#define N 9
int main()
{
\x05char *region[]={"not used",
\x05\x05"Atlantic Provinces",
\x05\x05"Quebec",
\x05\x05"not used",
\x05\x05"Ontario",
\x05\x05"not used",
\x05\x05"Prairie Provinces",
\x05\x05"British Columbia",
\x05\x05"not used",
\x05\x05"not used",
\x05};
\x05char SIN[N+1];
\x05printf("input %d digit SIN #:",N);
\x05fflush(stdin);
\x05fgets(SIN,N+1,stdin);
\x05
\x05int i=0;
\x05int step1_result[N/2];
\x05char step1[N]={'\0'};
\x05int step2_sum=0;
\x05//step 1 偶数位上的数乘以2,保存在数组step1_result中
\x05// 字符数组step1把上面的结果各位数字转换成对应数字字符保存起来
\x05while(i

计算机算法的题Develop an algorithm which takes as input a single 9-digit integer representing a Social Insurance Numbers (SIN) and determines whether or not it is valid.The algorithm should output if the SIN is valid or not.The rules determini 计算机的算法具有哪些特性? develop an article是什么意思有没有修改文章的意思 计算机编程常用算法有哪些?如题.A算法,遗传算法等等 计算机程序算法是什么意思 计算机图形学直线生成算法包含DDA算法,中点Bresenham算法,改进的Bresenham算法的完整c语言程序代码, 计算机图形学问题:编写中点分割的线段裁剪算法? 计算机图形学,光线跟踪算法的过程是什么 develop an interest in 能换成develop the interest 哪位计算机英语人才帮我翻译以下几段有关计算机的英语文章4Geometrical work of Ng et al. Intending to provide an animation tool that would quickly produce images of clothed objects, Ng et al.11,12 proposed a modeling techniq 计算机算法求算术表达式的值,分哪两步实现算法?急… 算法的优劣与算法描述语言无关,但与所用计算机有关对吗? 算法的优劣与算法描述语言有关,但与所用计算机无关对吗? 当今计算机的计算速度已相当高了,为什么还要研究算法与改进算法 在等差数列{an}中,a1=1,a2=3,an+2=3an+1-2an(n属于N+)II写出输入n(n>=3)值,输出a1,a2,……,an值的算法,并画出该算法的程序框图II根据(II)中的算法及框图,编写一个输入n值,输出a1,a2,……,an值的计算机 问一道计算机算法的题(10<8)or(10>8)结果是什么?答案是true. 计算机算法 用流程图表示 / 在计算机程序算法里面