fork download
  1. // 用意された質問の配列
  2. var predefinedQuestions = [
  3. "質問1",
  4. "質問2",
  5. "質問3",
  6. // 他の質問も同様に追加
  7. ];
  8.  
  9. // 質問のインデックス
  10. var questionIndex = 0;
  11.  
  12. // ChatGPTに質問を送信し、回答を取得する関数
  13. function askGPT(question) {
  14. // ChatGPTに質問を送信して回答を取得する処理をここに追加する
  15. // ここではダミーの回答を返す
  16. return "これはダミーの回答です。";
  17. }
  18.  
  19. // 質問と回答の処理を行う関数
  20. function askQuestions() {
  21. // 質問がまだ残っている場合
  22. if (questionIndex < predefinedQuestions.length) {
  23. var question = predefinedQuestions[questionIndex];
  24. // 質問をChatGPTに送信し、回答を取得
  25. var answer = askGPT(question);
  26. // 質問と回答を表示
  27. console.log("質問: " + question);
  28. console.log("回答: " + answer);
  29. // 次の質問のインデックスに移動
  30. questionIndex++;
  31. // 次の質問を行う
  32. askQuestions();
  33. } else {
  34. // 質問が終わったらHTML形式でダウンロードする
  35. downloadQuestionsAsHTML();
  36. }
  37. }
  38.  
  39. // 質問をHTML形式でダウンロードする関数
  40. function downloadQuestionsAsHTML() {
  41. // HTML形式のテキストを生成する
  42. var htmlContent = "<html><head><title>Predefined Questions and Answers</title></head><body><h1>Predefined Questions and Answers</h1><ul>";
  43.  
  44. // 質問と回答をリストとして追加する
  45. predefinedQuestions.forEach(function(question, index) {
  46. var answer = askGPT(question); // 回答を取得
  47. htmlContent += "<li><b>質問 " + (index + 1) + ":</b> " + question + "<br><b>回答:</b> " + answer + "</li>";
  48. });
  49.  
  50. htmlContent += "</ul></body></html>";
  51.  
  52. // HTMLファイルをダウンロードする
  53. var blob = new Blob([htmlContent], { type: "text/html" });
  54. var url = URL.createObjectURL(blob);
  55. var a = document.createElement("a");
  56. a.href = url;
  57. a.download = "predefined_questions_and_answers.html";
  58. document.body.appendChild(a);
  59. a.click();
  60. document.body.removeChild(a);
  61. URL.revokeObjectURL(url);
  62. }
  63.  
  64. // 質問と回答の処理を開始する
  65. askQuestions();
  66.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:2: error: class, interface, or enum expected
var predefinedQuestions = [
^
Main.java:10: error: class, interface, or enum expected
var questionIndex = 0;
^
Main.java:13: error: class, interface, or enum expected
function askGPT(question) {
^
Main.java:17: error: class, interface, or enum expected
}
^
Main.java:25: error: class, interface, or enum expected
        var answer = askGPT(question);
        ^
Main.java:27: error: class, interface, or enum expected
        console.log("??: " + question);
        ^
Main.java:28: error: class, interface, or enum expected
        console.log("??: " + answer);
        ^
Main.java:30: error: class, interface, or enum expected
        questionIndex++;
        ^
Main.java:32: error: class, interface, or enum expected
        askQuestions();
        ^
Main.java:33: error: class, interface, or enum expected
    } else {
    ^
Main.java:36: error: class, interface, or enum expected
    }
    ^
Main.java:45: error: class, interface, or enum expected
    predefinedQuestions.forEach(function(question, index) {
    ^
Main.java:47: error: class, interface, or enum expected
        htmlContent += "<li><b>?? " + (index + 1) + ":</b> " + question + "<br><b>??:</b> " + answer + "</li>";
        ^
Main.java:48: error: class, interface, or enum expected
    });
    ^
Main.java:50: error: class, interface, or enum expected
    htmlContent += "</ul></body></html>";
    ^
Main.java:53: error: class, interface, or enum expected
    var blob = new Blob([htmlContent], { type: "text/html" });
    ^
Main.java:54: error: class, interface, or enum expected
    var url = URL.createObjectURL(blob);
    ^
Main.java:55: error: class, interface, or enum expected
    var a = document.createElement("a");
    ^
Main.java:56: error: class, interface, or enum expected
    a.href = url;
    ^
Main.java:57: error: class, interface, or enum expected
    a.download = "predefined_questions_and_answers.html";
    ^
Main.java:58: error: class, interface, or enum expected
    document.body.appendChild(a);
    ^
Main.java:59: error: class, interface, or enum expected
    a.click();
    ^
Main.java:60: error: class, interface, or enum expected
    document.body.removeChild(a);
    ^
Main.java:61: error: class, interface, or enum expected
    URL.revokeObjectURL(url);
    ^
Main.java:62: error: class, interface, or enum expected
}
^
25 errors
stdout
Standard output is empty