C语言的结构类型
发布网友
发布时间:2022-04-29 17:15
我来回答
共3个回答
热心网友
时间:2023-10-22 16:13
修改如下:
//---------------------------------------------------------------------------
#include<stdio.h>
#include <conio.h>/*用到了getch()函数*/
struct date{
int month;
int day;
int year;
};
struct student{
long number;
char name[80];/*应该定义为字符数组*/
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name);/*gets()函数的参数是个字符指针,而不是字符变量*/
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&stud.score[0],&stud.score[1],&stud.score[2]);/*注意这里*/
printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
//---------------------------------------------------------------------------
热心网友
时间:2023-10-22 16:14
name 是个 char.所以只能输入一个字符
#include<stdio.h>
#include<conio.h>
struct date
{
int month;
int day;
int year;
};
struct student
{
long number;
char name[200];
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number = 10001L;
printf("Please input the name:");
gets(stud.name);
stud.birthday.year = 1981;
stud.birthday.year++;
stud.birthday.month = 8;
stud.birthday.day = 12;
stud.sex = 'm';
printf("Please input the score:");
scanf("%d %d %d", &score[0], &score[1], &score[2]);
printf("%d%s%c\n", stud.number, stud.name, stud.sex);
printf("birthday:%d-%d-%d\n", stud.birthday.month, stud.birthday.day, stud.birthday.year);
printf("score;%d,%d,%d", stud.score[0], stud.score[1], stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:14
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name); //这里要改成gets(&(stud.name))
~~~~~~~~~~~~~~~
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&score[0],&score[1],&score[2]); printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:13
修改如下:
//---------------------------------------------------------------------------
#include<stdio.h>
#include <conio.h>/*用到了getch()函数*/
struct date{
int month;
int day;
int year;
};
struct student{
long number;
char name[80];/*应该定义为字符数组*/
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name);/*gets()函数的参数是个字符指针,而不是字符变量*/
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&stud.score[0],&stud.score[1],&stud.score[2]);/*注意这里*/
printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
//---------------------------------------------------------------------------
热心网友
时间:2023-10-22 16:14
name 是个 char.所以只能输入一个字符
#include<stdio.h>
#include<conio.h>
struct date
{
int month;
int day;
int year;
};
struct student
{
long number;
char name[200];
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number = 10001L;
printf("Please input the name:");
gets(stud.name);
stud.birthday.year = 1981;
stud.birthday.year++;
stud.birthday.month = 8;
stud.birthday.day = 12;
stud.sex = 'm';
printf("Please input the score:");
scanf("%d %d %d", &score[0], &score[1], &score[2]);
printf("%d%s%c\n", stud.number, stud.name, stud.sex);
printf("birthday:%d-%d-%d\n", stud.birthday.month, stud.birthday.day, stud.birthday.year);
printf("score;%d,%d,%d", stud.score[0], stud.score[1], stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:14
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name); //这里要改成gets(&(stud.name))
~~~~~~~~~~~~~~~
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&score[0],&score[1],&score[2]); printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:13
修改如下:
//---------------------------------------------------------------------------
#include<stdio.h>
#include <conio.h>/*用到了getch()函数*/
struct date{
int month;
int day;
int year;
};
struct student{
long number;
char name[80];/*应该定义为字符数组*/
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name);/*gets()函数的参数是个字符指针,而不是字符变量*/
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&stud.score[0],&stud.score[1],&stud.score[2]);/*注意这里*/
printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
//---------------------------------------------------------------------------
热心网友
时间:2023-10-22 16:14
name 是个 char.所以只能输入一个字符
#include<stdio.h>
#include<conio.h>
struct date
{
int month;
int day;
int year;
};
struct student
{
long number;
char name[200];
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number = 10001L;
printf("Please input the name:");
gets(stud.name);
stud.birthday.year = 1981;
stud.birthday.year++;
stud.birthday.month = 8;
stud.birthday.day = 12;
stud.sex = 'm';
printf("Please input the score:");
scanf("%d %d %d", &score[0], &score[1], &score[2]);
printf("%d%s%c\n", stud.number, stud.name, stud.sex);
printf("birthday:%d-%d-%d\n", stud.birthday.month, stud.birthday.day, stud.birthday.year);
printf("score;%d,%d,%d", stud.score[0], stud.score[1], stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:14
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name); //这里要改成gets(&(stud.name))
~~~~~~~~~~~~~~~
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&score[0],&score[1],&score[2]); printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:13
修改如下:
//---------------------------------------------------------------------------
#include<stdio.h>
#include <conio.h>/*用到了getch()函数*/
struct date{
int month;
int day;
int year;
};
struct student{
long number;
char name[80];/*应该定义为字符数组*/
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name);/*gets()函数的参数是个字符指针,而不是字符变量*/
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&stud.score[0],&stud.score[1],&stud.score[2]);/*注意这里*/
printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
//---------------------------------------------------------------------------
热心网友
时间:2023-10-22 16:14
name 是个 char.所以只能输入一个字符
#include<stdio.h>
#include<conio.h>
struct date
{
int month;
int day;
int year;
};
struct student
{
long number;
char name[200];
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number = 10001L;
printf("Please input the name:");
gets(stud.name);
stud.birthday.year = 1981;
stud.birthday.year++;
stud.birthday.month = 8;
stud.birthday.day = 12;
stud.sex = 'm';
printf("Please input the score:");
scanf("%d %d %d", &score[0], &score[1], &score[2]);
printf("%d%s%c\n", stud.number, stud.name, stud.sex);
printf("birthday:%d-%d-%d\n", stud.birthday.month, stud.birthday.day, stud.birthday.year);
printf("score;%d,%d,%d", stud.score[0], stud.score[1], stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:13
修改如下:
//---------------------------------------------------------------------------
#include<stdio.h>
#include <conio.h>/*用到了getch()函数*/
struct date{
int month;
int day;
int year;
};
struct student{
long number;
char name[80];/*应该定义为字符数组*/
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name);/*gets()函数的参数是个字符指针,而不是字符变量*/
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&stud.score[0],&stud.score[1],&stud.score[2]);/*注意这里*/
printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
//---------------------------------------------------------------------------
热心网友
时间:2023-10-22 16:14
name 是个 char.所以只能输入一个字符
#include<stdio.h>
#include<conio.h>
struct date
{
int month;
int day;
int year;
};
struct student
{
long number;
char name[200];
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number = 10001L;
printf("Please input the name:");
gets(stud.name);
stud.birthday.year = 1981;
stud.birthday.year++;
stud.birthday.month = 8;
stud.birthday.day = 12;
stud.sex = 'm';
printf("Please input the score:");
scanf("%d %d %d", &score[0], &score[1], &score[2]);
printf("%d%s%c\n", stud.number, stud.name, stud.sex);
printf("birthday:%d-%d-%d\n", stud.birthday.month, stud.birthday.day, stud.birthday.year);
printf("score;%d,%d,%d", stud.score[0], stud.score[1], stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:14
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name); //这里要改成gets(&(stud.name))
~~~~~~~~~~~~~~~
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&score[0],&score[1],&score[2]); printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:14
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name); //这里要改成gets(&(stud.name))
~~~~~~~~~~~~~~~
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&score[0],&score[1],&score[2]); printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:13
修改如下:
//---------------------------------------------------------------------------
#include<stdio.h>
#include <conio.h>/*用到了getch()函数*/
struct date{
int month;
int day;
int year;
};
struct student{
long number;
char name[80];/*应该定义为字符数组*/
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name);/*gets()函数的参数是个字符指针,而不是字符变量*/
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&stud.score[0],&stud.score[1],&stud.score[2]);/*注意这里*/
printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}
//---------------------------------------------------------------------------
热心网友
时间:2023-10-22 16:14
name 是个 char.所以只能输入一个字符
#include<stdio.h>
#include<conio.h>
struct date
{
int month;
int day;
int year;
};
struct student
{
long number;
char name[200];
char sex;
struct date birthday;
int score[3];
};
int main(void)
{
int score[3];
struct student stud;
stud.number = 10001L;
printf("Please input the name:");
gets(stud.name);
stud.birthday.year = 1981;
stud.birthday.year++;
stud.birthday.month = 8;
stud.birthday.day = 12;
stud.sex = 'm';
printf("Please input the score:");
scanf("%d %d %d", &score[0], &score[1], &score[2]);
printf("%d%s%c\n", stud.number, stud.name, stud.sex);
printf("birthday:%d-%d-%d\n", stud.birthday.month, stud.birthday.day, stud.birthday.year);
printf("score;%d,%d,%d", stud.score[0], stud.score[1], stud.score[2]);
getch();
}
热心网友
时间:2023-10-22 16:14
int main(void)
{
int score[3];
struct student stud;
stud.number=10001L;
printf("Please input the name:");
gets(stud.name); //这里要改成gets(&(stud.name))
~~~~~~~~~~~~~~~
stud.birthday.year=1981;
stud.birthday.year++;
stud.birthday.month=8;
stud.birthday.day=12;
printf("Please input the score:");
scanf("%d%d%d",&score[0],&score[1],&score[2]); printf("%ld%s%4c\n",stud.number,stud.name,stud.sex);
printf("birthday:%d-%d-%d\n",stud.birthday.month,stud.birthday.day,stud.birthday.year);
printf("score;%d,%d,%d",stud.score[0],stud.score[1],stud.score[2]);
getch();
}