前5题完成
This commit is contained in:
parent
407877de30
commit
50ea136fdb
|
@ -2,5 +2,65 @@
|
|||
"C_Cpp.clang_format_style": "{ BasedOnStyle: Chromium, UseTab: Never, IndentWidth: 4, TabWidth: 4, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }",
|
||||
"files.associations": {
|
||||
"stdio.h": "c"
|
||||
}
|
||||
},
|
||||
"code-runner.executorMap": {
|
||||
"javascript": "node",
|
||||
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
|
||||
"c": "cd $dir && gcc -std=c11 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
|
||||
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
|
||||
"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
|
||||
"php": "php",
|
||||
"python": "python -u",
|
||||
"perl": "perl",
|
||||
"perl6": "perl6",
|
||||
"ruby": "ruby",
|
||||
"go": "go run",
|
||||
"lua": "lua",
|
||||
"groovy": "groovy",
|
||||
"powershell": "powershell -ExecutionPolicy ByPass -File",
|
||||
"bat": "cmd /c",
|
||||
"shellscript": "bash",
|
||||
"fsharp": "fsi",
|
||||
"csharp": "scriptcs",
|
||||
"vbscript": "cscript //Nologo",
|
||||
"typescript": "ts-node",
|
||||
"coffeescript": "coffee",
|
||||
"scala": "scala",
|
||||
"swift": "swift",
|
||||
"julia": "julia",
|
||||
"crystal": "crystal",
|
||||
"ocaml": "ocaml",
|
||||
"r": "Rscript",
|
||||
"applescript": "osascript",
|
||||
"clojure": "lein exec",
|
||||
"haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
|
||||
"rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
|
||||
"racket": "racket",
|
||||
"scheme": "csi -script",
|
||||
"ahk": "autohotkey",
|
||||
"autoit": "autoit3",
|
||||
"dart": "dart",
|
||||
"pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
|
||||
"d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
|
||||
"haskell": "runhaskell",
|
||||
"nim": "nim compile --verbosity:0 --hints:off --run",
|
||||
"lisp": "sbcl --script",
|
||||
"kit": "kitc --run",
|
||||
"v": "v run",
|
||||
"sass": "sass --style expanded",
|
||||
"scss": "scss --style expanded",
|
||||
"less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
|
||||
"FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
|
||||
"fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
|
||||
"fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
|
||||
"fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
|
||||
"sml": "cd $dir && sml $fileName"
|
||||
},
|
||||
"C_Cpp.default.compilerArgs": [
|
||||
"-g",
|
||||
"${file}",
|
||||
"-std=c11",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
]
|
||||
}
|
25
1/3.c
25
1/3.c
|
@ -1,19 +1,16 @@
|
|||
#include <stdio.h>
|
||||
|
||||
struct student {
|
||||
int id;
|
||||
float x, y, z;
|
||||
} stu[3];
|
||||
|
||||
int main() {
|
||||
// printf(" 1.Input\n");
|
||||
// printf(" 2.Output\n");
|
||||
// printf(" 3.Order\n");
|
||||
// printf(" 4.Quit\n");
|
||||
char m;
|
||||
scanf("%c", &m);
|
||||
if (m == 'I')
|
||||
printf("You are trying to input info");
|
||||
else if (m == 'O')
|
||||
printf("You are trying to output info");
|
||||
else if (m == 'D')
|
||||
printf("You are trying to make things ordered");
|
||||
else if (m == 'Q')
|
||||
printf("You are about to quit");
|
||||
scanf("%d,%f,%f,%f", &stu[0].id, &stu[0].x, &stu[0].y, &stu[0].z);
|
||||
scanf("%d,%f,%f,%f", &stu[1].id, &stu[1].x, &stu[1].y, &stu[1].z);
|
||||
scanf("%d,%f,%f,%f", &stu[2].id, &stu[2].x, &stu[2].y, &stu[2].z);
|
||||
printf("%d,%7.1f,%7.1f,%7.1f\n", stu[0].id, stu[0].x, stu[0].y, stu[0].z);
|
||||
printf("%d,%7.1f,%7.1f,%7.1f\n", stu[1].id, stu[1].x, stu[1].y, stu[1].z);
|
||||
printf("%d,%7.1f,%7.1f,%7.1f", stu[2].id, stu[2].x, stu[2].y, stu[2].z);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#include <stdio.h>
|
||||
|
||||
struct student {
|
||||
int id;
|
||||
float x, y, z;
|
||||
float sum;
|
||||
} stu[3];
|
||||
|
||||
void swap(struct student* a, struct student* b) {
|
||||
struct student c;
|
||||
c = *a;
|
||||
*a = *b;
|
||||
*b = c;
|
||||
}
|
||||
|
||||
void sort() {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3 - i - 1; j++) {
|
||||
if (stu[j].sum < stu[j + 1].sum) {
|
||||
swap(&stu[j], &stu[j + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
scanf("%d,%f,%f,%f", &stu[0].id, &stu[0].x, &stu[0].y, &stu[0].z);
|
||||
scanf("%d,%f,%f,%f", &stu[1].id, &stu[1].x, &stu[1].y, &stu[1].z);
|
||||
scanf("%d,%f,%f,%f", &stu[2].id, &stu[2].x, &stu[2].y, &stu[2].z);
|
||||
stu[0].sum = stu[0].x + stu[0].y + stu[0].z;
|
||||
stu[1].sum = stu[1].x + stu[1].y + stu[1].z;
|
||||
stu[2].sum = stu[2].x + stu[2].y + stu[2].z;
|
||||
sort();
|
||||
printf("%d,%.1f\n", stu[0].id, stu[0].sum);
|
||||
printf("%d,%.1f\n", stu[1].id, stu[1].sum);
|
||||
printf("%d,%.1f\n", stu[2].id, stu[2].sum);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#include <stdio.h>
|
||||
|
||||
struct student {
|
||||
int id, c;
|
||||
float x, y, z;
|
||||
float sum;
|
||||
} stu[3];
|
||||
|
||||
void swap(struct student* a, struct student* b) {
|
||||
struct student c;
|
||||
c = *a;
|
||||
*a = *b;
|
||||
*b = c;
|
||||
}
|
||||
|
||||
void sort() {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3 - i - 1; j++) {
|
||||
if (stu[j].c > stu[j + 1].c || (stu[j].c == stu[j + 1].c && stu[j].sum < stu[j + 1].sum)) {
|
||||
swap(&stu[j], &stu[j + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
scanf("%d,%d,%f,%f,%f", &stu[0].c, &stu[0].id, &stu[0].x, &stu[0].y, &stu[0].z);
|
||||
scanf("%d,%d,%f,%f,%f", &stu[1].c, &stu[1].id, &stu[1].x, &stu[1].y, &stu[1].z);
|
||||
scanf("%d,%d,%f,%f,%f", &stu[2].c, &stu[2].id, &stu[2].x, &stu[2].y, &stu[2].z);
|
||||
stu[0].sum = stu[0].x + stu[0].y + stu[0].z;
|
||||
stu[1].sum = stu[1].x + stu[1].y + stu[1].z;
|
||||
stu[2].sum = stu[2].x + stu[2].y + stu[2].z;
|
||||
sort();
|
||||
printf("%d,%d,%.1f\n", stu[0].c, stu[0].id, stu[0].sum);
|
||||
printf("%d,%d,%.1f\n", stu[1].c, stu[1].id, stu[1].sum);
|
||||
printf("%d,%d,%.1f\n", stu[2].c, stu[2].id, stu[2].sum);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue