实验室作业(元旦)

学习成果

C语言

跟着老师学完了C语言基础,现在可以比较熟练的运用指针链表等知识点。

链表插入删除示例

#include<stdio.h>
#include<stdlib.h>

/*创建结构体*/
struct node
{
	char name[20];
	int float;
	struct node *next;
}

/*创建*/
struct student *creat(int n)
{
	struct student *head=NULL;
	struct student *pnew, *ptail;
	int i;
	pnew =(struct student *)malloc(sizeof(struct student));
	scanf("%s %f",pnew->name,&pnew->score);
	head = pnew;
	ptail =pnew;
	for (i=1;i<n;i++)
	{
		pnew =(struct student *)malloc(sizeof(struct student));
		scanf("%s %f",pnew->name,&pnew->score);
		ptail->next =pnew;
		ptail =pnew;
	}
	ptail->next =NULL;
	return head;
}

/*输出函数*/
void print(struct student *head)
{
	struct student *p=head;
	while(p!=NULL)
	{
		printf("%s %.1f \n",p->name,p->score);
		p=p->next;
	}
}

/*删除函数*/
struct student *del(struct student *head, int *flag)
{
	struct student *p =head, *pold =head;
	*flag =0;
	if (head ==NULL)
	return head;	
	if(head->score>=60)
	{
		head =head->next;
		free(p);
		*flag =1;
	}
	else
	while(p!=NULL)
	{
		if(p->score>=60)
		{
			pold->next=p->next;
			free(p);
			*flag =1;
			break;
		}
		else{pold=p;p=p->next;}
	}
	return head;
}

/*插入*/
struct student *insert(struct student *head)
{
	struct student *p,*pnew,*pold;
	pnew = (struct student*)malloc(sizeof(struct student));
	scanf("%s %f",pnew->name,&pnew->score);
	p =head;
	if (pnew->score>head->score)
	{pnew->next =head;head=pnew;}
	else
	{
		while(p!=NULL&&pnew->score<p->score)
		{
			pold =p;
			p=p->next;}
			pnew->next=p;
			pold->next=pnew;
		}
	return head;
}

/*主函数*/
int main()
{
	struct student *creat(int n);
	 void print(struct student *head);
	 struct student *del(struct student *head, int *flag);
	 struct student *insert(struct student *head);
 	struct student *head;
	 int f=1,n;
	 printf("Please input a number:\n");
	 scanf("%d",&n);
	 printf("Please input a the linked-list:\n");
	 head =creat(n);
 	printf("Insert a new vaule\n");
	 head =insert(head);
	 print(head); 
	 printf("delete the failed student\n");
	 do
	 { 
	 	 head =del(head,&f);
	 }
	 while(f!=0);
	 print(head);  
 	printf("Insert a new vaule\n");
	 head =insert(head);
	 print(head);
	 return 0;
}

Python

python进度略为尴尬,虽然实验室大佬已经讲完了爬虫,但是自己进度比较慢有点跟不上进度,所以现在只学会了python的基础函数操作。
例如:对列表,字典,类的操作。

python示例

users = {
        'aeinstein':{
                'first':'albert',
                'last':'einstein',
                'location':'princeton',
        },
        
        'mcurie':{
                'first':'marie',
                'last':'curie',
                'location':'paris',
                },
                
    }
        
for username, user_info in users.items():
    print("\nUsername:" + username)
    full_name = user_info['first'] + " " + user_info['last']
    location = user_info['location']
    
    print("\tFull name:" + full_name.title())
    print("\tlocation:" + location.title())

?????

whlie示例

responses = {}

polling_active = True

while polling_active:
    name = input("\nWhat is your name?")
    response = input("Which mountain would you like to clumb someday?")
    
    responses[name] = response
            
    repeat = input("Would you like to let another person respond?(yes/no)")
    if repeat == 'no':
        polling_active = False
    
print("\n--- Poll Results ---")
for name, response in responses.items():
    print(name + "would like to climb" + response + '.')

?????

实验室建议

讲道理其实没啥建议,不过大佬们讲的快是真的,我菜也是真的。?

哈哈,其实也没啥了,这半年讲实话没学到什么,有点浑浑噩噩,需要改变。

就这样吧。
学长新年快乐!☀️☀️

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值