From 5c94bfbca5b70ee72bae3ae92d759ed1b6ee69b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=A1=E5=9D=82=E6=98=B4?= Date: Wed, 25 Sep 2024 21:10:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90=E5=AE=9E?= =?UTF-8?q?=E9=AA=8C1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 33 +++++++++++++++++++++++++++++++++ .vscode/tasks.json | 28 ++++++++++++++++++++++++++++ test1.cpp | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 test1.cpp diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d9fa3c7 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,33 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) 启动", + "type": "cppdbg", + "request": "launch", + "program": "输入程序名称,例如 ${workspaceFolder}/a.out", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "为 gdb 启用整齐打印", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "将反汇编风格设置为 Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + } + + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..5d4653d --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc 生成活动文件", + "command": "/usr/bin/gcc", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "调试器生成的任务。" + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/test1.cpp b/test1.cpp new file mode 100644 index 0000000..0a708f9 --- /dev/null +++ b/test1.cpp @@ -0,0 +1,33 @@ +#include +#include + +using namespace std; + +typedef struct book +{ + string no; + string name; + double price; +} book; + +int main() +{ + book books[100]; + int i = 0; + + // input + for (i; true; i++) + { + cin >> books[i].no >> books[i].name >> books[i].price; + if (books[i].no == "0" && books[i].name == "0" && books[i].price == 0) + { + break; + } + } + // output + cout << i + 1 << endl; + for (int j = 0; j <= i; j++) + { + cout << books[j].no << "\t" << books[j].name << "\t" << setprecision(2) << books[j].price << endl; + } +} \ No newline at end of file