|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#define counter 5
struct student
{
int num;
char name[20];
float score;
};
struct student stu[counter]={{1,"陈璐",90},{2,"邓琳琳",78},{3,"陈乐",50},{4,"刘浩",85},{5,"章文苗",45}};
void modify(int inNum)
{
int i;
struct student *p=&stu[0];
for(i=0;i<counter;i++,p++)
if(p[i].num==inNum)
{
printf("请输入成绩:");
scanf("%f", );
}
}
int main()
{
int i,num;
printf("请输入需要修改成绩的学生学号:");
scanf("%d",&num);
modify(num);
printf("修改后学生成绩如下:\n");
for(i=0;i<counter;i++)
printf("%d\t%s\t%.2f\n",stu[i].num, ,stu[i].score);
printf("\n");
return 0;
}
#include <stdio.h>
#define counter 5
struct student{
int num;
char name[20];
float score;
};
struct student stu[counter] = {{1, "陈璐", 90}, {2, "邓琳琳", 78}, {3, "陈乐", 50}, {4, "刘浩", 85}, {5, "章文苗", 45}};
void modify(int inNum){
int i;
struct student *p = &stu[0];
for(i = 0; i < counter; i++, p++)
if(p[i].num==inNum){
printf("请输入成绩:");
scanf("%f", &p[i].score);
}
}
int main(){
int i, num;
printf("请输入需要修改成绩的学生学号:");
scanf("%d", &num);
modify(num);
printf("修改后学生成绩如下:\n");
for(i = 0; i < counter; i++)
printf("%d\t%s\t%.2f\n", stu[i].num, stu[i].name, stu[i].score);
printf("\n");
return 0;
}
|
|