结构体数组与指针
。
提示:以下是本篇文章正文内容,下面案例可供参考
代码如下(示例):
#include <stdio.h>
#define N 3
struct stu{
int num;
char name[32];
double score;
double ave;
};
void input(struct stu *p, int n);
void sort(struct stu *p, int n);
void show(struct stu *p, int n);
int main(){
struct stu a[N];
input(a,N);
sort(a,N);
show(a,N);
return 0;
}
void input(struct stu *p, int n){
for(int i=0; i<n; i++){
printf("请输入学生%d:\n",i+1);
printf("name: ");
scanf("%s",p[i].name);
printf("请输入成绩: \n");
scanf("%lf",&p[i].score);
}
}
void sort(struct stu *p,int n){
for(int i=0; i<n-1;i++)
for(int j=0;j<n-i-1;j++){
if(p[j].score<p[j+1].score){
struct stu b = p[j];
p[j] = p[j+1];
p[j+1]= b;
}
}
}
void show(struct stu *p, int n){
printf("\n NO. \t name \t 平均成绩 \n");
for(int i=0; i<n; i++){
printf("%d \t %s \t %0.2f\n",i+1,p[i].name,p[i].score);
}
}
2.读入数据
代码如下(示例):
data = pd.read_csv(
'https://labfile.oss.aliyuncs.com/courses/1283/adult.data.csv')
print(data.head())
该处使用的url网络请求的数据。
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。