Parcourir la source

just for save file

tangs il y a 7 ans
Parent
commit
12ce97ed7c
3 fichiers modifiés avec 64 ajouts et 11 suppressions
  1. 9 0
      section3-3/CMakeLists.txt
  2. 55 0
      section3-3/section3-3.cpp
  3. 0 11
      section3-3/section3-3/section33.cpp

+ 9 - 0
section3-3/CMakeLists.txt

@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.6)
+project(section3_3)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+
+set(SOURCE_FILES
+        section3-3.cpp)
+
+add_executable(section3_3 ${SOURCE_FILES})

+ 55 - 0
section3-3/section3-3.cpp

@@ -0,0 +1,55 @@
+#include <iostream>
+#include <vector>
+
+using namespace std;
+
+struct Grade {
+    string Id;
+    int Score;
+};
+
+int main() {
+    int N = 0, M = 0, G = 0;
+    int *questions;
+
+    while (cin >> N && N) {
+        cin >> M >> G;
+
+        questions = new int[M];
+        vector<Grade> grade;
+
+        // input question scoreIndex
+        for (int i = 0; i < M; i++) {
+            cin >> questions[i];
+        }
+
+        int answer;
+        int total, scoreIndex;
+        string id;
+        for (int i = 0; i < N; i++) {
+            answer = 0;
+            total = 0, scoreIndex = 0;
+            cin >> id;
+            cin >> answer;
+            answer = answer > M ? M : answer;
+            for (int j = 0; j < answer; j++) {
+                cin >> scoreIndex;
+                total += questions[scoreIndex];
+            }
+            if (total < G) {
+                continue;
+            }
+            Grade tempGrade = {id, total};
+            grade.push_back(tempGrade);
+        }
+
+        for (int i = 0; i < (grade.size()); i++) {
+            cout << "id: " << grade.at(i).Id << "; scoreIndex: " << grade.at(i).Score << endl;
+        }
+
+        // free
+        free(questions);
+        grade.clear();
+    }
+}
+

+ 0 - 11
section3-3/section3-3/section33.cpp

@@ -1,11 +0,0 @@
-// section33.cpp: 定义控制台应用程序的入口点。
-//
-
-#include "stdafx.h"
-
-
-int main()
-{
-    return 0;
-}
-