#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点数解答]
相关提问
- [GPT] #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)229
- [GPT] #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)198
- [字节豆包] 求一个圆柱体的表面积和体积。从键盘输入圆柱体的半径和高,输出它的表面积和体积。 函数接口定义: 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)248
- [字节豆包] #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)238
- [阿里通义] #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)256
- [字节豆包] 本题要求实现一个计算输入的两数的和与差的简单函数。 函数接口定义: 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)204
- [字节豆包] #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)196
- [字节豆包] 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)222
- 实验目的: 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)354
- [字节豆包] 题目描述 给定m行n列的图像各像素点的灰度值,要求用如下方法对其进行模糊化处理: 1.四周最外侧的像素点灰度值不变; 2.中间各像素点新灰度值为该像素点及其上下左右相邻四个像素点原灰度值的平均值(四舍五入)。 输入格式 第一行包含两个整数n和m,表示图像包含像素点的行数和列数。1<=n<=100,1<=m<=100。 接下来n行,每行m个整数,表示图像的每个像素点灰度。相邻两个整数之间用单个空格隔开,每个元素均在0~255之间。 输出格式 m行,每行n个整数,为模糊处理后的图像。相邻两个整数之间用单个空格隔开。 输入样例1 4 5 100 0 100 0 50 50 100 200 0 0 50 50 100 100 200 100 100 50 50 100 输出样例1 100 0 100 0 50 50 80 100 60 0 50 80 100 90 200 100 100 50 50 100 用c++语言 (670点数解答 | 2025-11-10 18:55:33)39
- [字节豆包] 题目描述 给定m行n列的图像各像素点的灰度值,要求用如下方法对其进行模糊化处理: 1.四周最外侧的像素点灰度值不变; 2.中间各像素点新灰度值为该像素点及其上下左右相邻四个像素点原灰度值的平均值(四舍五入)。 输入格式 第一行包含两个整数n和m,表示图像包含像素点的行数和列数。1<=n<=100,1<=m<=100。 接下来n行,每行m个整数,表示图像的每个像素点灰度。相邻两个整数之间用单个空格隔开,每个元素均在0~255之间。 输出格式 m行,每行n个整数,为模糊处理后的图像。相邻两个整数之间用单个空格隔开。 输入样例 4 5 100 0 100 0 50 50 100 200 0 0 50 50 100 100 200 100 100 50 50 100 输出样例 100 0 100 0 50 50 80 100 60 0 50 80 100 90 200 100 100 50 50 100 说明/提示 用c++(655点数解答 | 2025-12-01 14:24:01)15
- [字节豆包] #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)170