学习成果
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 + '.')
?????
实验室建议
讲道理其实没啥建议,不过大佬们讲的快是真的,我菜也是真的。?
哈哈,其实也没啥了,这半年讲实话没学到什么,有点浑浑噩噩,需要改变。
就这样吧。
学长新年快乐!☀️☀️