當前位置:編程學習大全網 - 編程軟體 - 1. 編程:定義壹個學生(姓名、學號、性別、年齡、成績),通過鍵盤輸入壹個學生信息,並打印出學生信息。

1. 編程:定義壹個學生(姓名、學號、性別、年齡、成績),通過鍵盤輸入壹個學生信息,並打印出學生信息。

#include <stdio.h>

typedef struct

{

char name[30];

long num;

char sex[5];

int age;

float score;

} student;

void main()

{

student stu;

printf("請輸入學生的信息如下:\n");

printf("學生姓名:");

gets(stu.name);

printf("學生學號:");

scanf("%ld",&stu.num);

getchar();

printf("學生性別(男-M; 女-F):");

gets(stu.sex);

printf("學生成績:");

scanf("%f",&stu.score);

printf("您輸入的學生信息如下:\n");

printf("學生姓名:%s\n",stu.name);

printf("學生學號:%ld\n",stu.num);

printf("學生性別:%s\n",stu.sex);

printf("學生成績:%.2f\n",stu.score);

}

  • 上一篇:基因編輯嬰兒會帶來什麽風險,帶來什麽倫理道德問題?
  • 下一篇:UG繪制波紋管連波浪線都省了!
  • copyright 2024編程學習大全網