We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include<stdio.h> #include<stdlib.h> #include<memory.h> struct lian { int num; struct lian *next; }; struct lian *hcreat(int n) { int i=1; struct lian*hang=NULL,*cut,*end; cut=end=(struct lian*)malloc(sizeof(struct lian)); scanf_s("%d",&cut->num); while(cut->num!=999) { i++; if(hang==NULL) hang=cut; else { end->next=cut; end=cut; end=cut=(struct lian*)malloc(sizeof(struct lian)); scanf_s("%d",&cut->num); } } end->next=NULL; return(hang); } struct lian *lcreat(int n) { struct lian *lie=NULL,*cut,*end; int i=1; cut=end=(struct lian*)malloc(sizeof(struct lian)); scanf_s("%d",&cut->num); while(cut->num!=999) { i++; if(lie==NULL) lie=cut; else { end->next=cut; end=cut; end=cut=(struct lian*)malloc(sizeof(struct lian)); scanf_s("%d",&cut->num); } } return(lie); } struct lian *chen(struct lian*hang,struct lian*lie,int n) { int i=0,s=0; struct lian*zui=NULL,*cut,*end; while(hang!=NULL) { i++; s+=hang->num*lie->num; if(i%n==0) { end=cut=(struct lian*)malloc(sizeof(struct lian)); memset(cut,0,sizeof(struct lian)); cut->num=s; if(zui==NULL) zui=cut; else { end->next=cut; end=cut; } s=0; } } end->next=NULL; return(zui); } void print(struct lian *zui,int n) { struct lian *a; int i=1; a=zui; if(a==NULL) { printf("这是空链表"); exit(1); } else while(a!=NULL) { printf("%d",a->num); a=a->next; if(i%n==0) printf("\n"); i++; } } int main() { struct lian *hang,*lie,*zui; hang=lie=zui=(struct lian*)malloc(sizeof(struct lian)); int n; printf("请输入矩阵的阶数:\n"); scanf_s("%d",&n); printf("请输入第一个矩阵:\n"); hang=hcreat(n); hang->next=NULL; printf("请输入第二个矩阵:\n"); lie=lcreat(n); lie->next=NULL; zui=chen(hang,lie,n); zui->next=NULL; printf("最后结果为:\n"); print(zui,n); return 0; }
The text was updated successfully, but these errors were encountered:
点评:
0x0F6D5290 (vcruntime140d.dll) (Project1.exe 中)处有未经处理的异常: 0xC0000005: 写入位置 0x00000000 时发生访问冲突。
输入:
请输入矩阵的阶数: 3 请输入第一个矩阵: 1 2 3 1 2 3 1 2 3 999 请输入第二个矩阵: 1 2 3 4 5 6 7 8 9 999
修改!
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: