Skip to content
New issue

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

常澳 矩阵相乘 (才发现没交呢) #29

Open
chuyhu opened this issue Nov 29, 2018 · 1 comment
Open

常澳 矩阵相乘 (才发现没交呢) #29

chuyhu opened this issue Nov 29, 2018 · 1 comment
Labels
修改 代码出现问题,请修改后重新提交代码

Comments

@chuyhu
Copy link

chuyhu commented Nov 29, 2018

#include <stdio.h>
#include <stdlib.h>
struct ju{
    int a;
    struct ju*next;
}*h1,h2,*h3,*p,*q,*s,*o,*l;
//创建链表
void creat()
{
    int a,n;
    int i=1;
    scanf("%d",&n);//判断矩阵的阶数
    scanf("%d",&a);//矩阵内输入值
    h1=NULL;        //头指针为空
    //前面的矩阵  以行的形式输入
    for(int j=1;j<=1000;j++)
    {
        while(i<=1000)
        {
            s=(struct *)malloc(sizeof(stu ju));
            s->a=a;        
            //完成连接操作
            if(h1==NULL)
            {
                h1=s;
                p=s;
            }
            else
            {
                p->next=s;
                p=p->next;
            }   
            i++;
            scanf("%d",&a);
         } 
    }
    //第二个矩阵  以列的形式输入
    int b;
     for(int j=1;j<=1000;j++)
    {
        while(i<=1000)
        {
            s=(struct *)malloc(sizeof(struct ju));
            s->a=b;        
            //完成连接操作
            if(h2==NULL)
            {
                h2=s;
                q=s;
            }
            else
            {
                q->next=s;
                q=q->next;
            }   
            i++;
            scanf("%d",&b);
         } 
    }
    //乘积得值
void cheng()
{
    p=h1;
    q=h2;
    h3=NULL;
    int x=1;
    for(int m=1;p==NULL;m++)
    {
        p=p->next;
        if(m%1000==0)
        {
            for(int n=1;q==NULL;n++)
            {
                q=q->next;
                if(n%1000==0)
                {
                    while(x!=1000)
                    {
                        o=(struct *)malloc(sizeof(struct ju));
                        o->a=(p->a)*(q->a);
                        if(h3==NULL)
                        {
                            h3=o;
                            l=o;
                        }
                        else
                        {
                            l->next=o;
                            o=o->next;
                        }
                        x++;
                    }
                }   
            }
    }
}
void print()
{
    l=h3;
    while(l==NULL)
    {
        printf("%d",l->a);
        l=l->next;
    }
}
int main()
{
    creat();
    cheng();
    print();
    system("pause");
    return 0;
}
@wmpscc
Copy link
Member

wmpscc commented Dec 7, 2018

点评:

  • 编译未通过,请修改

修改!

@wmpscc wmpscc added the 修改 代码出现问题,请修改后重新提交代码 label Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
修改 代码出现问题,请修改后重新提交代码
Projects
None yet
Development

No branches or pull requests

2 participants