1.#include
#include
#include
struct labor
{
char number[10];
int salary;
struct labor *next;
};
struct labor *creat()
{
struct labor *head,*tail,*p;
int salary;
char number[10];
head=tail=NULL;
printf("Please enter the number:");
scanf("%s",number);
printf("Please enter the salary:");
scanf("%d",&salary);
printf("当salary输入为0输入结束\n\n");
while(salary)
{
p=(struct labor*)malloc(sizeof(struct labor));
strcpy(p->number,number);
p->salary=salary;
p->next=NULL;
if(head==0)
head=p;
else
tail->next=p;
tail=p;
printf("Please enter the number:");
scanf("%s",number);
printf("Please enter the salary:");
scanf("%d",&salary);
printf("当salary输入为0输入结束\n\n");
}
return head;
}
void list(struct labor *head)
{
struct labor *ptr;
if(head==NULL)
{ printf("No list found"); return;}
for(ptr=head;ptr!=NULL;ptr=ptr->next)
{
printf("the number:%s\n",ptr->number);
printf("the salary:%d\n\n",ptr->salary);
}
}
void zggz()
{
struct labor *head;
head=creat();
list(head);
printf("结束,按任意键回到主菜单......");
getch();
}
2.#include
void qnnh()
{
int t=0,s=0,i,n;
printf("输入一个0-10之间的数\n",n);
scanf("%d",&n);
for(i=1;i<=n;i++)
{t=i+t*10;s=s+t;}
printf("s=%d\n",s);
printf("结束,按任意键回到主菜单......");
getch();
}
第一个做的比较简单。不过应该应付的过去。
同学,您可真是够懒的~~
不过估计会有人帮你做的,偶路过~