#include <stdio.h> #include <stdlib.h> // 定义图书结构体 typedef struct { char title[50]; char author[50]; float price; } book; // 定义图书表 book booktable[100]; int bookcount = 0; // 根据指定图书个数,逐个输入图书信息 void inputbookinfo(int count) { for (int i = 0; i < count; i++) { printf("请输入第%d本图书的标题:", i+1); scanf(" %[^\n]", booktable[bookcount].title); printf("请输入第%d本图书的作者:", i+1); scanf(" %[^\n]", booktable[bookcount].author); printf("请输入第%d本图书的价格:", i+1); scanf("%f", &booktable[bookcount].price); bookcount++; }


} int main() { int count; printf("请输入要录入的图书数量:"); scanf("%d", &count); inputbookinfo(count); printf("\n图书录入完成,录入的图书信息如下:\n"); for (int i = 0; i < bookcount; i++) { printf("图书%d:\n", i+1); printf("%s\n", booktable[i].title); printf("作者:%s\n", booktable[i].author); printf("价格:%.2f\n", booktable[i].price); } return 0; } // 示例输入和输出 // 输入 // 请输入要录入的图书数量:2 // 请输入第1本图书的C Programming // 请输入第1本图书的作者:K&R // 请输入第1本图书的价格:20.5 // 请输入第2本图书的Introduction to Algorithms // 请输入第2本图书的作者:Cormen // 请输入第2本图书的价格:30.0 // 输出 // 图书录入完成,录入的图书信息如下: // 图书1: // C Programming // 作者:K&R // 价格:20.50 // 图书2: // Introduction to Algorithms // 作者:Cormen // 价格:30.00 [2024-07-01 00:38:33 | AI写代码神器 | 559点数解答]
相关提问
- #include <stdio.h> #include <stdlib.h> // 定义图书结构体 typedef struct { char title[50]; char author[50]; float price; } book; // 定义图书表 book booktable[100]; int bookcount = 0; // 根据指定图书个数,逐个输入图书信息 void inputbookinfo(int count) { for (int i = 0; i < count; i++) { printf("请输入第%d本图书的标题:", i+1); scanf(" %[^\n]", booktable[bookcount].title); printf("请输入第%d本图书的作者:", i+1); scanf(" %[^\n]", booktable[bookcount].author); printf("请输入第%d本图书的价格:", i+1); scanf("%f", &booktable[bookcount].price); bookcount++; }(559点数解答 | 2024-07-01 00:38:33)216
- #include <iostream> #include <iomanip> #include <string> using namespace std; struct < n; i++) { char id[30], title[100]; float price book { ; cin >> id >> title >> price; // string id; // 书号 读入书号、书名和价格 addbook(id, title, price); cin.ignore(); // 处理掉 string title; // 书换行符 } // 输入查找次数 cin >> m; //名 float price; // 价格 查找每 book* next; // 指向下一个节点的指次针 }; class booklist { public: booklist() : head指定(nullptr)位置 {} void addbook(const string& id, const string& title, float price) { book* newbook =(2245点数解答 | 2024-12-18 09:06:13)176
- 求一个圆柱体的表面积和体积。从键盘输入圆柱体的半径和高,输出它的表面积和体积。 函数接口定义: float area(float r,float h); //求圆柱体的表面积 float bulk(float r,float h);//求圆柱体的体积 裁判测试程序样例: #include<stdio.h> #define pi 3.1415926 // 用 pi 表示 π 的值 float area(float r, float h); float bulk(float r, float h); main() {float r,h; //r表示底面积半径,h表示圆柱体高度 scanf("%f,%f",&r,&h); printf("surface area :%.2f, volume :%.2f\n",area(r,h),bulk(r,h)); } /* 你提交的代码将被嵌入到该行的下面*/(248点数解答 | 2024-12-15 23:04:16)218
- #include<stdio.h> #include<stdlib.h> #include<time.h> int producerand(int remainder); void initprocess(); void chosedisplace(); struct linknode* fifo(struct linknode* head, int randcount); void optimal(struct linknode* head, int randprocess); struct linknode* lru(struct linknode* head, int randprocess); struct linknode* initlink(); void choicestey(); int allotment(struct linknode* head); int checkfifooptimal(struct linknode* head, int checkpage); void recover(struct linknode* head, int randproc(60点数解答 | 2024-12-13 20:02:21)209
- #include<stdio.h> #include<stdlib.h> #include<time.h> int producerand(int remainder); void initprocess(); void chosedisplace(); struct linknode* fifo(struct linknode* head, int randcount); void optimal(struct linknode* head, int randprocess); struct linknode* lru(struct linknode* head, int randprocess); struct linknode* initlink(); void choicestey(); int allotment(struct linknode* head); int checkfifooptimal(struct linknode* head, int checkpage); void recover(struct linknode* head, int randproc(858点数解答 | 2024-12-13 20:03:47)195
- 本题要求实现一个计算输入的两数的和与差的简单函数。 函数接口定义: void sum_diff( float op1, float op2, float *psum, float *pdiff ); 其中op1和op2是输入的两个实数,*psum和*pdiff是计算得出的和与差。 裁判测试程序样例: #include <stdio.h> void sum_diff( float op1, float op2, float *psum, float *pdiff ); int main() { float a, b, sum, diff; scanf("%f %f", &a, &b); sum_diff(a, b, &sum, &diff); printf("the sum is %.2f\nthe diff is %.2f\n", sum, diff); return 0; } /* 你的代码将被嵌在这里 */ 用c语言(128点数解答 | 2024-12-01 21:36:04)175
- #include<iostream> #include<string> #include<iomanip> #include<fstream> #include<stdlib.h> using namespace std; #define ok 1 #define error 0 #define overflow -2 typedef int status; //status 是函数返回值类型,其值是函数结果状态代码。 typedef int elemtype; //elemtype 为可定义的数据类型,此设为int类型 struct book { string id;//isbn string name;//书名 double price;//定价 }; typedef struct lnode { book data; //结点的数据域 struct lnode *next; //结点的指针域 } lnode, *linklist; //linklist为指向结构体lnode的指针类型 string head_1, head_2, head_3; int lengt(35点数解答 | 2024-10-31 17:38:15)175
- c语言现在想将学生绩点组成一个链表。链表结点内容包括学生姓名,学号,绩点。 输入是一组学生的姓名、学号和绩点,以链表形式存储,结点顺序即学生信息的输入顺序。 请在原链接中删除绩点小于平均绩点的学生结点,然后按照输入的顺序,依序输出新链表的学生信息。 平均绩点是输入的所有学生绩点取算术平均值。 1.本题中,头文件已经添加,且学生结点和头结点定义如下: #include<stdio.h> #include<stdbool.h> #include<stdlib.h> #include<string.h> // 学生结点定义 typedef struct student { char name[20];//姓名 char no[20];//学号 float grade;//绩点 struct student *next; } stu; // 头结点定义 typedef struct { int n; //学生个数 float sum;//学生绩点和 float avg;//平均绩点 stu *first; } he(604点数解答 | 2024-12-03 11:10:47)198
- 实验目的: 1.巩固理解java的面向对象程序设计概念 2.理解java封装的含义 3.理解static, final等关键字的含义及应用实验内容: 定义 book类,给每一本书自动赋上索书号 is sn1, issn2... 声明一个图书类,其数据成员为书名、编号(利用静态变量实现自动编号“issn1” “is sn2”) 书价,册数和静态属性图书的总册数,在构造方法中利用静态变量为对象的编号赋值,在主方法中 定义对象数组,并求出总册数。运行效果如下: 【书名]:java程序书名]:java程序书名]:ava程序 书名j:c语言程序设计书名]:c语言程序设计书名]:null 书名]:nul1 [书名]:nu11 【价格]:35.6 【价格]:35.6 【价格]:35.6 [价格]:42.6 [价格]:42.6 [价格]:8.日 [价格]:8.8 [价格]:8.0 [图书線号]:issn1图书编号]:issn2[图书编号):issn3[图书编号j:issn4图书编号]:issn5图书線号】:issn6[图书線号]:issn7[图书編号]:issn8 [本书的册数]:3 [本书的册数]:(1469点数解答 | 2024-04-02 10:20:41)319
- #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #define maxsize 100 typedef char elemtype; typedef struct node { elemtype data; struct node* lchild; struct node* rchild; } btnode; typedef struct { btnode* data[maxsize]; int top; } stacktype; void initstack(stacktype* st) { st->top = -1; } bool stackempty(stacktype* st) { return st->top == -1; } bool push(stacktype* st, btnode* e) { if (st->top < maxsize - 1) { st->data[++st->top] = e;(95点数解答 | 2024-12-10 13:17:25)142
- #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <time.h> #include <conio.h> #include <unistd.h> #define mapheight 24 #define mapwidth 60 struct { int x; int y; } bean; struct { int x; int y; } eater; int key; int score1=0; void gotoxy(int x,int y); void drawmap(); void createbean(); void updatescore(); void keydown(); //0.光标 void gotoxy(int x,int y) { //控制输出时的光标位置 handle hout = getstdhandle(std_output_handle); coord pos; pos.x =x; pos.y =y; setconsolecursorpos(66点数解答 | 2024-11-15 22:33:26)205
- #include <stdio.h> int i; struct stu { char num; char name; int grade[3] }; void input(struct stu stu) { scanf("%s%s", &stu.num, &stu.name); for (int i = 0; i < 3; i++) { scanf("%d", &stu.grade); } } void print(struct stu stu) { printf("%s,%s,", stu.num, stu.name); for (i = 0; i < 2; i++) { printf("%d,", a.grade[i]); }printf("%d\n",stu.grade[2]); } int main() { int n; struct stu a; scanf("%d", &n); for ( i = 0; i < n; i++) { input(a); } for (i = 0; i < n; i++) { print((371点数解答 | 2025-01-03 23:31:22)130