-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
20 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
// 使用 IntelliSense 了解相关属性。 | ||
// 悬停以查看现有属性的描述。 | ||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
|
||
|
||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"tasks": [ | ||
{ | ||
"type": "cppbuild", | ||
"label": "C/C++: gcc.exe 生成活动文件", | ||
"command": "C:\\msys64\\ucrt64\\bin\\gcc.exe", | ||
"args": [ | ||
"-fdiagnostics-color=always", | ||
"-g", | ||
"${file}", | ||
"-o", | ||
"${fileDirname}\\${fileBasenameNoExtension}.exe" | ||
], | ||
"options": { | ||
"cwd": "${fileDirname}" | ||
}, | ||
"problemMatcher": [ | ||
"$gcc" | ||
], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"detail": "调试器生成的任务。" | ||
} | ||
], | ||
"version": "2.0.0" | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
// 定义学生结构体 | ||
typedef struct { | ||
char name[100]; // 姓名字符串 | ||
char id[20]; // 学号字符串 | ||
float scores[3]; // 三门课程的成绩 | ||
} Student; | ||
|
||
int main() { | ||
Student student; | ||
FILE *file; | ||
|
||
// 提示用户输入学生的姓名和学号 | ||
printf("请输入学生的姓名:"); | ||
fgets(student.name, sizeof(student.name), stdin); | ||
student.name[strcspn(student.name, "\n")] = 0; // 去除换行符 | ||
|
||
printf("请输入学生的学号:"); | ||
fgets(student.id, sizeof(student.id), stdin); | ||
student.id[strcspn(student.id, "\n")] = 0; // 去除换行符 | ||
|
||
// 提示用户输入三门课程的成绩 | ||
for (int i = 0; i < 3; i++) { | ||
printf("请输入第%d门课程的成绩:", i + 1); | ||
scanf("%f", &student.scores[i]); | ||
} | ||
|
||
// 清除输入缓冲区中的换行符 | ||
getchar(); | ||
|
||
// 打开文件用于写入 | ||
file = fopen("d:\\aaa.txt", "w"); | ||
if (file == NULL) { | ||
printf("无法打开文件!"); | ||
return 1; | ||
} | ||
|
||
// 将学生信息写入文件 | ||
fprintf(file, "姓名:%s 学号:%s", student.name, student.id); | ||
for (int i = 0; i < 3; i++) { | ||
fprintf(file, "第%d门课程成绩:%f", i + 1, student.scores[i]); | ||
} | ||
|
||
// 关闭文件 | ||
fclose(file); | ||
|
||
printf("学生信息已成功写入到d:\\aaa.txt文件中。"); | ||
|
||
return 0; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <iostream> | ||
#include <vector> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"}; | ||
|
||
for (const string& word : msg) | ||
{ | ||
cout << word << " "; | ||
} | ||
cout << endl; | ||
} |