mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 21:16:45 +08:00
update
This commit is contained in:
@@ -12,12 +12,12 @@
|
||||
"translatedContent": "<p>编写一个可以从 1 到 n 输出代表这个数字的字符串的程序,但是:</p>\n\n<ul>\n\t<li>如果这个数字可以被 3 整除,输出 \"fizz\"。</li>\n\t<li>如果这个数字可以被 5 整除,输出 \"buzz\"。</li>\n\t<li>如果这个数字可以同时被 3 和 5 整除,输出 \"fizzbuzz\"。</li>\n</ul>\n\n<p>例如,当 <code>n = 15</code>,输出: <code>1, 2, fizz, 4, buzz, fizz, 7, 8, fizz, buzz, 11, fizz, 13, 14, fizzbuzz</code>。</p>\n\n<p>假设有这么一个类:</p>\n\n<pre>\nclass FizzBuzz {\n public FizzBuzz(int n) { ... } // constructor\n public void fizz(printFizz) { ... } // only output \"fizz\"\n public void buzz(printBuzz) { ... } // only output \"buzz\"\n public void fizzbuzz(printFizzBuzz) { ... } // only output \"fizzbuzz\"\n public void number(printNumber) { ... } // only output the numbers\n}</pre>\n\n<p>请你实现一个有四个线程的多线程版 <code>FizzBuzz</code>, 同一个 <code>FizzBuzz</code> 实例会被如下四个线程使用:</p>\n\n<ol>\n\t<li>线程A将调用 <code>fizz()</code> 来判断是否能被 3 整除,如果可以,则输出 <code>fizz</code>。</li>\n\t<li>线程B将调用 <code>buzz()</code> 来判断是否能被 5 整除,如果可以,则输出 <code>buzz</code>。</li>\n\t<li>线程C将调用 <code>fizzbuzz()</code> 来判断是否同时能被 3 和 5 整除,如果可以,则输出 <code>fizzbuzz</code>。</li>\n\t<li>线程D将调用 <code>number()</code> 来实现输出既不能被 3 整除也不能被 5 整除的数字。</li>\n</ol>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>本题已经提供了打印字符串的相关方法,如 <code>printFizz()</code> 等,具体方法名请参考答题模板中的注释部分。</li>\n</ul>\n\n<p> </p>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 113,
|
||||
"likes": 116,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Fizz Buzz\", \"titleSlug\": \"fizz-buzz\", \"difficulty\": \"Easy\", \"translatedTitle\": \"Fizz Buzz\", \"isPaidOnly\": false}, {\"title\": \"Print Zero Even Odd\", \"titleSlug\": \"print-zero-even-odd\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u6253\\u5370\\u96f6\\u4e0e\\u5947\\u5076\\u6570\", \"isPaidOnly\": false}]",
|
||||
"contributors": [],
|
||||
"langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python\": true, \"python3\": true, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false, \"cangjie\": false}",
|
||||
"langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python3\": true, \"python\": true, \"javascript\": false, \"typescript\": false, \"csharp\": false, \"c\": false, \"golang\": false, \"kotlin\": false, \"swift\": false, \"rust\": false, \"ruby\": false, \"php\": false, \"dart\": false, \"scala\": false, \"elixir\": false, \"erlang\": false, \"racket\": false, \"cangjie\": false, \"bash\": false, \"html\": false, \"pythonml\": false, \"react\": false, \"vanillajs\": false, \"mysql\": false, \"mssql\": false, \"postgresql\": false, \"oraclesql\": false, \"pythondata\": false}",
|
||||
"topicTags": [
|
||||
{
|
||||
"name": "Concurrency",
|
||||
@@ -40,12 +40,6 @@
|
||||
"code": "class FizzBuzz {\n private int n;\n\n public FizzBuzz(int n) {\n this.n = n;\n }\n\n // printFizz.run() outputs \"fizz\".\n public void fizz(Runnable printFizz) throws InterruptedException {\n \n }\n\n // printBuzz.run() outputs \"buzz\".\n public void buzz(Runnable printBuzz) throws InterruptedException {\n \n }\n\n // printFizzBuzz.run() outputs \"fizzbuzz\".\n public void fizzbuzz(Runnable printFizzBuzz) throws InterruptedException {\n \n }\n\n // printNumber.accept(x) outputs \"x\", where x is an integer.\n public void number(IntConsumer printNumber) throws InterruptedException {\n \n }\n}",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "Python",
|
||||
"langSlug": "python",
|
||||
"code": "class FizzBuzz(object):\n def __init__(self, n):\n self.n = n\n\n # printFizz() outputs \"fizz\"\n def fizz(self, printFizz):\n \"\"\"\n :type printFizz: method\n :rtype: void\n \"\"\"\n \t\n\n # printBuzz() outputs \"buzz\"\n def buzz(self, printBuzz):\n \"\"\"\n :type printBuzz: method\n :rtype: void\n \"\"\"\n \t\n\n # printFizzBuzz() outputs \"fizzbuzz\"\n def fizzbuzz(self, printFizzBuzz):\n \"\"\"\n :type printFizzBuzz: method\n :rtype: void\n \"\"\"\n \n\n # printNumber(x) outputs \"x\", where x is an integer.\n def number(self, printNumber):\n \"\"\"\n :type printNumber: method\n :rtype: void\n \"\"\"\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "Python3",
|
||||
"langSlug": "python3",
|
||||
@@ -53,9 +47,9 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "C",
|
||||
"langSlug": "c",
|
||||
"code": "typedef struct {\n int n;\n} FizzBuzz;\n\nFizzBuzz* fizzBuzzCreate(int n) {\n FizzBuzz* obj = (FizzBuzz*) malloc(sizeof(FizzBuzz));\n obj->n = n;\n return obj;\n}\n\n// printFizz() outputs \"fizz\".\nvoid fizz(FizzBuzz* obj) {\n \n}\n\n// printBuzz() outputs \"buzz\".\nvoid buzz(FizzBuzz* obj) {\n \n}\n\n// printFizzBuzz() outputs \"fizzbuzz\".\nvoid fizzbuzz(FizzBuzz* obj) {\n \n}\n\n// You may call global function `void printNumber(int x)`\n// to output \"x\", where x is an integer.\nvoid number(FizzBuzz* obj) {\n \n}\n\nvoid fizzBuzzFree(FizzBuzz* obj) {\n \n}",
|
||||
"lang": "Python",
|
||||
"langSlug": "python",
|
||||
"code": "class FizzBuzz(object):\n def __init__(self, n):\n self.n = n\n\n # printFizz() outputs \"fizz\"\n def fizz(self, printFizz):\n \"\"\"\n :type printFizz: method\n :rtype: void\n \"\"\"\n \t\n\n # printBuzz() outputs \"buzz\"\n def buzz(self, printBuzz):\n \"\"\"\n :type printBuzz: method\n :rtype: void\n \"\"\"\n \t\n\n # printFizzBuzz() outputs \"fizzbuzz\"\n def fizzbuzz(self, printFizzBuzz):\n \"\"\"\n :type printFizzBuzz: method\n :rtype: void\n \"\"\"\n \n\n # printNumber(x) outputs \"x\", where x is an integer.\n def number(self, printNumber):\n \"\"\"\n :type printNumber: method\n :rtype: void\n \"\"\"\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
@@ -63,9 +57,15 @@
|
||||
"langSlug": "csharp",
|
||||
"code": "public class FizzBuzz {\n private int n;\n\n public FizzBuzz(int n) {\n this.n = n;\n }\n\n // printFizz() outputs \"fizz\".\n public void Fizz(Action printFizz) {\n \n }\n\n // printBuzzz() outputs \"buzz\".\n public void Buzz(Action printBuzz) {\n \n }\n\n // printFizzBuzz() outputs \"fizzbuzz\".\n public void Fizzbuzz(Action printFizzBuzz) {\n \n }\n\n // printNumber(x) outputs \"x\", where x is an integer.\n public void Number(Action<int> printNumber) {\n \n }\n}",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "C",
|
||||
"langSlug": "c",
|
||||
"code": "typedef struct {\n int n;\n} FizzBuzz;\n\nFizzBuzz* fizzBuzzCreate(int n) {\n FizzBuzz* obj = (FizzBuzz*) malloc(sizeof(FizzBuzz));\n obj->n = n;\n return obj;\n}\n\n// Don't change the following declarations\nvoid printNumber(int a);\nvoid printFizz();\nvoid printBuzz();\nvoid printFizzBuzz();\n\n// printFizz() outputs \"fizz\".\nvoid fizz(FizzBuzz* obj) {\n \n}\n\n// printBuzz() outputs \"buzz\".\nvoid buzz(FizzBuzz* obj) {\n \n}\n\n// printFizzBuzz() outputs \"fizzbuzz\".\nvoid fizzbuzz(FizzBuzz* obj) {\n \n}\n\n// You may call global function `void printNumber(int x)`\n// to output \"x\", where x is an integer.\nvoid number(FizzBuzz* obj) {\n \n}\n\nvoid fizzBuzzFree(FizzBuzz* obj) {\n \n}",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"25.9K\", \"totalSubmission\": \"39.5K\", \"totalAcceptedRaw\": 25888, \"totalSubmissionRaw\": 39486, \"acRate\": \"65.6%\"}",
|
||||
"stats": "{\"totalAccepted\": \"28K\", \"totalSubmission\": \"42.5K\", \"totalAcceptedRaw\": 28030, \"totalSubmissionRaw\": 42481, \"acRate\": \"66.0%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
|
Reference in New Issue
Block a user