请大家帮忙补充一下这四个程序
小女不胜感激啊
谢谢啊!!^^
祝大家开心!
1、以下程序求a数组中所有素数之和,函数isprime用来判断自变量是否为素数,素数x是能被1和它本身整除大于1的自然数。请补充完整程序
#include "____①________"
main()
{int i, a[____②___],*p=a, sum=____③______;
Printf("Enter 10 num:\n");
for(i=0; i<10; i++) scanf("%d",___④_____);
if(isprime(*(p+____⑤_____))==1)
{ printf("&d",*(a+i));
sum+=*(a+i);
}
printf("\n The sum=%d\n",__⑥___);
}
isprime(int x)
{ int___⑦_____;
for(i=2;___⑧_____;i++)
if(x%i==0) return(0);
if(x>1) return(1);
else return(0);
}
⑵以下程序为结构数组接收10个人的姓名、年龄和性别。然后输出,请补充完整程序
Struc man
{_①___name[20];
unsigned age;
char sex[7];
};
main()
{___②__person[10];
data_in(person);
data_out(__③____);
}
data_in(p)
Struct map *p;
{ struct man *q=__④______;
for(;p<q;p++)
{Printf("age;sex;name");
scanf("%u%s",p→age,p→sex);
___⑤____;
}
}
data_out(p)
__⑥_____*p;
{Struct man *q=___⑦___;
for(;p<q;p++)
Printf("%s;%u;__⑧____\n",p→age,p→sex);
}
⑶以下程序对10个字符串由小到大的顺序排列。main函数对字符串赋初值并输出排序结果。(其中strcmp(srt1,srt2)为字符串比较函数;若srt1<srt2 则函数值为一负数;若srt1=srt2 则函数值为0;若srt1>srt2 则函数值为一正数)
#include "stdio.h"
main()
{void sort(char *s[],int n);
char *str[10]={"java","prolog","pl","lisp","logo","VB","fortran","cobol","pascal","c++"};
int i;
sort(__①____);
Printf("new seguence of strigs is:\n");
for(___②___;___③___;___④________)
Printf("%s\n",str[i]);
}
Void sort(char *s[],int n)
{char *temp;
int i,j;
for(i=0;i<n;i++)
for(i=0;j<n;j++)
if(strcmp(s[i],s[j])<0)
{_⑤___=s[i];
__⑥__=__⑦__;
s[j]=__⑧__;}
}
⑷以下f函数功能是:在带有头结点单向链表中,查找结点数据域的最大值作为函数返回值
Struct book
Struct book
{int a;
__①___*next;
}
int f(struct book *pl)
{___②___*p2;
p2=p1→next
m=p2→a;
for(p2=p2→next;p2!='\0';p2=__③___)
if(___④____)m=p2→a;
return__⑤___;
}