|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 超级无敌磊果果 于 2019-1-20 20:55 编辑
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#define N 10
typedef struct ss
{ char num[10];
int s;
} STU;
fun(STU a[], STU *s)
{
int i,j,n=0;
int temp = a[0].s;
for(i=0;i<N;i++)
{
if(a[i].s < temp)
{
temp = a[i].s;
n = i;
}
}
s->num[10] = a[n].num; //这一行程序出来的是乱码,请问怎么修改
s->s = temp;
}
void main()
{
FILE *wf;
STU a[N]={{ "A01",81},{ "A02",89},{ "A03",66},{ "A04",87},{ "A05",77},
{ "A06",90},{ "A07",79},{ "A08",61},{ "A09",80},{ "A10",71}},m;
int i;
system("CLS");
printf("*****The original data*****\n");
for(i=0;i<N;i++)
printf("No=%s Mark=%d\n", a[i].num,a[i].s);
fun(a,&m);
printf("*****THE RESULT*****\n");
printf("The lowest :%s, %d\n",m.num,m.s);
/******************************/
wf=fopen("out.dat","w");
fprintf(wf,"%s, %d",m.num,m.s);
fclose(wf);
/*****************************/
}
你是要把数组a[n].num的值赋给数组s->num么 int i;
for (i=0;i<10;++i)
s->num[i]=a[n].num[i];
|
|