#7974: 為什麼都是CE??


webber1994 (webber)

學校 : 國立臺灣海洋大學
編號 : 33553
來源 : [140.117.197.49]
最後登入時間 :
2016-09-14 22:33:15
a010. 因數分解 | From: [1.34.160.35] | 發表日期 : 2013-07-19 13:36

這是我的程式碼

#include<stdio.h>

#include<stdlib.h>

#define MAX 100000

typedef struct element * pointer;

struct element{

int value;

pointer rlink;

};

int main()

{

element *a,*header;

a = (element*)malloc(sizeof(element));

header = a;

int i,num,count[MAX];

while(scanf("%d",&num) != EOF)

{

for(i=0;i<MAX;i++)

count[i] = 0;

a = header;i = 2;

while(i <= num)

{

if(num % i == 0)

{

a->value = i;

count[i]++;

a->rlink = (element*)malloc(sizeof(element));

a = a->rlink;

num /= i;

continue;

}

i++;

}

a->value = -1;

for(a = header;a->value != -1;a = a->rlink)

{

if(a->rlink->value != -1)

{

if(count[a->value] > 1 && a->value != a->rlink->value) printf("%d^%d * ",a->value,count[a->value]);

if(count[a->value] == 1) printf("%d * ",a->value);

}

if(a->rlink->value == -1)

{

if(count[a->value] > 1 && a->value != a->rlink->value) printf("%d^%d\n",a->value,count[a->value]);

if(count[a->value] == 1) printf("%d\n",a->value);

}

}

}

free(a);

return 0;

有哪位高手可以幫我找出是哪裡有問題嗎?

謝謝 

 
ZeroJudge Forum