[刷题] PTA 查验身份证】的更多相关文章

题目: 7-63 查验身份证 (15 分)  一个合法的身份证号码由17位地区.日期编号和顺序编号加1位校验码组成.校验码的计算规则如下: 首先对前17位数字加权求和,权重分配为:{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}:然后将计算的和对11取模得到值Z:最后按照以下关系对应Z值与校验码M的值: Z:0 1 2 3 4 5 6 7 8 9 10 M:1 0 X 9 8 7 6 5 4 3 2 现在给定一些身份证号码,请你验证校验码的有效性,并输出有问题的号码.…
链表逆序 1 #include<iostream> 2 #include<stdio.h> 3 #include<algorithm> 4 using namespace std; 5 #define MAXSIZE 1000010 6 7 struct node { 8 int data; 9 int next; 10 } node[MAXSIZE]; 11 12 int List[MAXSIZE]; 13 int main() { 14 int First,n,k;…
用栈实现树遍历 1 #include<stdio.h> 2 #include<string.h> 3 #define MAXSIZE 30 4 5 int Pre[MAXSIZE],In[MAXSIZE],Post[MAXSIZE]; 6 void solve(int preL,int inL,int postL,int n); 7 void outPut(int p[],int n); 8 9 int main(){ 10 int n,tmp,i,j = 0; 11 int to…
程序: 1 #include<stdio.h> 2 #include<string.h> 3 #define N 81 4 5 int main() { 6 char ch[N],temp[N]; 7 int i,cnt,lng=0; 8 scanf("%d",&cnt); 9 gets(ch); 10 strcpy(temp,ch); 11 for(i=0; i<cnt; i++) { 12 gets(ch); 13 if(strlen(ch)&…
我的程序: 1 #include<stdio.h> 2 #include<string.h> 3 #define N 50 4 char token[]= {'+','-','*','/','(',')'}; 5 6 int istoken(char c) { 7 int i; 8 for(i=0; i<strlen(token); i++) { 9 if(token[i]==c) return 1; 10 } 11 return 0; 12 } 13 14 int main…
程序: 1 #include <stdio.h> 2 #include <stdlib.h> 3 typedef struct TreeNode *Tree; 4 struct TreeNode{ 5 int v; 6 Tree Left,Right; 7 int flag; 8 }; 9 Tree NewNode(int V){ 10 Tree T=(Tree)malloc(sizeof(struct TreeNode)); 11 T->v = V; 12 T->Le…
程序: 1 #include <stdio.h> 2 #include <queue> 3 #define MaxTree 20 4 #define Null -1 5 using namespace std; 6 7 struct TreeNode { 8 int Left; 9 int Right; 10 } T[MaxTree]; 11 int N,check[MaxTree]; 12 int count = 0; 13 14 int BuildTree(struct Tre…
程序: 1 #include <stdio.h> 2 #define MaxTree 10 3 #define ElementType char 4 #define Tree int 5 #define Null -1 6 7 struct TreeNode { 8 ElementType Element; 9 Tree Left; 10 Tree Right; 11 } T1[MaxTree],T2[MaxTree]; 12 int N,check[MaxTree]; 13 14 Tree…
程序: 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 typedef int ElementType; 5 typedef struct Node *PtrToNode; 6 struct Node { 7 ElementType Data; 8 PtrToNode Next; 9 }; 10 typedef PtrToNode List; 11 12 List Read(); /* 细节在此不表 */ 13 void Print(…
模拟栈进出 方法一: 1 #include<stdio.h> 2 #define MAXSIZE 1000 3 4 typedef struct{ 5 int data[MAXSIZE]; 6 int top; 7 }SqStack; 8 9 int InitStack(SqStack *s){ 10 s->top=-1; 11 return 0; 12 } 13 14 int Push(SqStack *s,int e){ 15 if(s->top==MAXSIZE) retur…