C语言结构上机实验报告,小弟在这里先谢谢各位程序猿大婶了

1.定义一个反映学生基本情况的结构类型,用以存储学生的相关信息(学生信息结构类型:由学号、姓名、性别和生日共4项组成)。
2.利用定义的结构类型struct std_info,定义一个结构变量student,用于存储和显示一个学生的基本情况。

帮你现写的一个程序如下:

#include <stdio.h>
 
typedef struct student
{
 int id;//学号
 char name[30];//姓名
 int gender; //性别(0为男生,1为女生)
 char birth[30];//生日
}stu;
 
int main()
{
 stu s[2];
 int i;
 for(i=0;i<2;i++)
 {
  printf("请输入第%d个学生的学号:",i+1);
  scanf("%d",&s[i].id);
  printf("请输入第%d个学生的姓名:",i+1);
  scanf("%s",&s[i].name);
  printf("请输入第%d个学生的性别:",i+1);
  scanf("%d",&s[i].gender);
  printf("请输入第%d个学生的生日:",i+1);
  scanf("%s",&s[i].birth);
 }
 printf("这几个学生的信息如下:\n");
 for(i=0;i<2;i++)
  printf("%d\t%s\t%d\t%s\n",s[i].id,s[i].name,s[i].gender,s[i].birth);
 return 0;
}

运行结果如下:

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-06-19
#include<stdio.h>
#include<string.h>
typedef struct std_info
{
    int id;
    char name[20];
    char sex[5];
    char birthday[20];
}student;
void main()
{
    student st;
    st.id=110;
    strcpy(st.name,"zhang");
    strcpy(st.sex,"n");
    strcpy(st.birthday,"1994-4-1");
    printf("%d %s %s %s\n",st.id,st.name,st.sex,st.birthday);
}

追问

。。。太少了吧 需要的是实验报告的格式

追答

实验报告??? 还有写1000字???

追问

没那么多,大部分都是代码,不过我看同学写的很多啊,都是3,4业纸