求大神帮忙解答C语言感激不尽!!!!!!!!!!!
1.写出以下程序的输出结果#include<stdio.h>voidmain(void){struct{intx;inty;}a={5,7},*p=&a;printf("...
1. 写出以下程序的输出结果
#include<stdio.h>
void main(void )
{
struct {
int x;
int y;
} a={ 5,7}, *p=&a;
printf("%d\n",++p->x);
}
2、写出以下程序的输出结果
#include<stdio.h>
struct a{
int x;
int y;
};
voidfun(struct a *c)
{
struct a u={12, 13 };
*c=u;
}
voidmain( )
{
struct a m={21,23};
fun(&m);
printf("%d %d\n",m.x,m.y);
}
3、写出以下程序的输出结果
#include<stdio.h>
structSTU {
char name[10];
int num;
int Score;
};
voidmain( )
{
struct STU s[5]= {
{"YangSan",20041,703},
{"LiSiGuo",20042,580},
{"wangYin",20043,680},
{"SunDan",20044,550},
{"Penghua",20045,537}
}, *p[5], *t;
int i, j;
for(i=0;i<5;i++)
p[i]=&s[i];
for(i=0;i<4;i++){
for(j=i+1;j<5;j++){
if(p[i]->Score >p[j]->Score){
t=p[i];
p[i]=p[j];
p[j]=t;
}
}
}
printf("%d %d\n", s[1].Score, p[1]->Score);
} 展开
#include<stdio.h>
void main(void )
{
struct {
int x;
int y;
} a={ 5,7}, *p=&a;
printf("%d\n",++p->x);
}
2、写出以下程序的输出结果
#include<stdio.h>
struct a{
int x;
int y;
};
voidfun(struct a *c)
{
struct a u={12, 13 };
*c=u;
}
voidmain( )
{
struct a m={21,23};
fun(&m);
printf("%d %d\n",m.x,m.y);
}
3、写出以下程序的输出结果
#include<stdio.h>
structSTU {
char name[10];
int num;
int Score;
};
voidmain( )
{
struct STU s[5]= {
{"YangSan",20041,703},
{"LiSiGuo",20042,580},
{"wangYin",20043,680},
{"SunDan",20044,550},
{"Penghua",20045,537}
}, *p[5], *t;
int i, j;
for(i=0;i<5;i++)
p[i]=&s[i];
for(i=0;i<4;i++){
for(j=i+1;j<5;j++){
if(p[i]->Score >p[j]->Score){
t=p[i];
p[i]=p[j];
p[j]=t;
}
}
}
printf("%d %d\n", s[1].Score, p[1]->Score);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询