Discuss Scratch
- Discussion Forums
- » 日本語
- » Scratch以外のプログラミング言語やってる人交流場
- ymt2
-
Scratcher
1 post
Scratch以外のプログラミング言語やってる人交流場
<!DOCTYPE html>
<html lang=“ja”>
<head>
<meta charset=“UTF-8”>
<title>今Htmlを勉強してます</title>
</head>
<body>
始めたばかりです
</body>
</html>
<html lang=“ja”>
<head>
<meta charset=“UTF-8”>
<title>今Htmlを勉強してます</title>
</head>
<body>
始めたばかりです
</body>
</html>
Last edited by ymt2 (Sept. 20, 2021 00:25:47)
- Y_M-H
-
Scratcher
34 posts
Scratch以外のプログラミング言語やってる人交流場
jsの変数のから判定が全くできないんですよ。
getElementByIdでidを取得してから.valueをつけて、if(!variable.value)みたいなことをしてもから判定にならなくて….
getElementByIdでidを取得してから.valueをつけて、if(!variable.value)みたいなことをしてもから判定にならなくて….
- itta611
-
Scratcher
100+ posts
Scratch以外のプログラミング言語やってる人交流場
checkboxですか?
もし、普通のtextのinputなら、なお、JSファイルの先頭に'use strict';をつけて、何かエラーは出ていませんか?条件式の部分をconsole.logで出力してみてください。
もし、普通のtextのinputなら、なお、JSファイルの先頭に'use strict';をつけて、何かエラーは出ていませんか?条件式の部分をconsole.logで出力してみてください。
Last edited by itta611 (Sept. 20, 2021 01:04:29)
- arss2
-
Scratcher
3 posts
Scratch以外のプログラミング言語やってる人交流場
(Githubアカウント持ってない人来れ!HTMLって使いやすいですよね(私も使っています)。
まずは自己紹介からいくか
・mtaiking
ミケケとかえむた主とかよんでほしい
・Githubアカウント
mtaiking(現在)
imystars(旧)
・やってる言語(やってる順)
1.HTML
1.enchant.js
3.Python
3.Swift
・使用OS
Mac OS X 10.10.3
よろすくです。
- tsumuri3
-
Scratcher
1000+ posts
Scratch以外のプログラミング言語やってる人交流場
AtCoderサイトの規約上、明日になるまでコードは貼れませんが、
何回やってもコンパイルエラーって出ます。
(ユーザースクリプトの名前)で、Sb3→C++です。
これのバグとか知ってたら教えてください。
※AtCoder競技中はこれについて正解に近いものを絶対に言わないこと。
終了時刻は22:40:00です。
何回やってもコンパイルエラーって出ます。
(ユーザースクリプトの名前)で、Sb3→C++です。
これのバグとか知ってたら教えてください。
※AtCoder競技中はこれについて正解に近いものを絶対に言わないこと。
終了時刻は22:40:00です。
Last edited by tsumuri3 (Sept. 26, 2021 13:50:46)
- tsumuri3
-
Scratcher
1000+ posts
Scratch以外のプログラミング言語やってる人交流場
終わったようなので、コードを公開します。
問題は一番簡単な奴です。
https://atcoder.jp/contests/abc220/tasks/abc220_a
C++です。
提出したコードはこれです。
問題は一番簡単な奴です。
https://atcoder.jp/contests/abc220/tasks/abc220_a
C++です。
提出したコードはこれです。
/* ユーザースクリプトの名前(クレジット表記) */ #include <iostream> #include <stdlib.h> #include <string> #include <vector> #include <algorithm> #include <math.h> #define debug cerr << "--" << __LINE__ << "--" << "\n" typedef long long ll; using namespace std; class Var{ // NOTE: immutable public: mutable string sval; mutable long double dval; enum NumericState {UNKNOWN = -1, STRINGY = 0, NUMERIC = 1}; mutable NumericState numericState; mutable bool svalValid, dvalValid; // TODO: initialize at here? Var(){ *this = Var(""); } Var(string s){ sval = s; svalValid = true; dvalValid = false; numericState = UNKNOWN; } Var(long double d){ dval = d; svalValid = false; dvalValid = true; numericState = NUMERIC; } Var(const Var &v){ sval = string(v.sval); dval = v.dval; svalValid = v.svalValid; dvalValid = v.dvalValid; numericState = v.numericState; } void fillDval() const{ if (dvalValid) return; long double d; bool numeric = isNumericString(sval, &d); if (numeric){ numericState = NUMERIC; dval = d; }else{ numericState = STRINGY; dval = 0.0; } dvalValid = true; } static bool isNumericString(const string &s, long double *ptr) { char* ep; // cause side-effect: errno can be ERANGE after calling strtod *ptr = strtold(s.c_str(), &ep); // Scratch 3.0 recognize the string cause underflows or overflows as Numeric return NULL != ep && '\0' == ep[0] && s[0] != '\0'; } bool isNumeric() const{ fillDval(); return numericState == NUMERIC; } void fillSval() const{ if (svalValid) return; sval = (floorl(dval) == dval) ? to_string((ll)dval) : to_string(dval); svalValid = true; } long double asNumber() const{ fillDval(); return dval; } string asString() const{ fillSval(); return sval; } Var operator+(const Var &y) const{ return Var(this->asNumber() + y.asNumber()); } Var operator+=(const Var &y){ *this = *this + y; return *this; } Var operator-(const Var &y) const{ return Var(this->asNumber() - y.asNumber()); } Var operator*(const Var &y) const{ return Var(this->asNumber() * y.asNumber()); } Var operator/(const Var &y) const{ return Var(this->asNumber() / y.asNumber()); } Var operator%(const Var &y) const{ return Var(fmodl(this->asNumber(), y.asNumber())); } bool operator<(const Var &y) const{ if (this->isNumeric() && y.isNumeric()){ return this->asNumber() < y.asNumber(); } // compare as number if both can be interpreted as numeric return this->asString() < y.asString(); } bool operator>(const Var &y) const{ return y < *this; } bool operator==(const Var &y) const{ if (this->isNumeric() && y.isNumeric()){ return this->asNumber() == y.asNumber(); } // compare as numeric if both are numeric return this->asString() == y.asString(); } friend ostream& operator << (ostream& os, const Var& p); friend istream& operator >> (istream& is, const Var& p); }; ostream& operator << (ostream& os, const Var& p){ os << p.asString(); return os; } istream& operator >> (istream& is, Var& p){ string s; is >> s; p = Var(s); return is; } Var letterOf(Var index, Var sourceString){ /* index: 1-origined */ string str = sourceString.asString(); int idx = (int)(index.asNumber() - 1); // seem to be dirty but Scratch seems to do like this. // ex. letterOf(0.01, "world") == "w", letterOf(1.99, "world") == "w", letterOf(5.99, "world") == "d" if (0 <= idx && idx < str.size()) return Var(str.substr(idx, 1)); return Var(); } class VarList{ public: vector<Var> data; VarList(const vector<Var> &x) { data = x; } void push_back(const Var &x){ data.push_back(x); } void pop_back(){ data.pop_back(); } void clear(){ data.clear(); } int size(){ return (int) data.size(); } Var getLineOfList(const Var &index) const{ /* index: 1-origined */ int idx = (int)index.asNumber() - 1; // (unlike 'letterOf', index==0.9 does not work.) if (0 <= idx && idx < data.size()) return data[idx]; return Var(); } void setLineOfListTo(const Var &index, const Var &v){ /* index: 1-origined */ int idx = (int)index.asNumber() - 1; if (0 <= idx && idx < data.size()) data[idx] = v; } void deleteLineOfList(const Var &index){ /* index: 1-origined */ string kwd = index.asString(); if (kwd == "all"){ data.clear(); }else if (kwd == "last"){ data.pop_back(); }else{ int idx = (int)index.asNumber() - 1; if (0 <= idx && idx < data.size()) data.erase(data.begin() + idx); } } void insertAtIndexOfList(const Var &item, const Var &index){ /* index: 1-origined */ int idx = (int)index.asNumber() - 1; if (0 <= idx && idx <= data.size()) data.insert(data.begin() + idx, item); } void insertAtRandomOfList(const Var &item){ int idx = rand() % (data.size() + 1); data.insert(data.begin() + idx, item); } string asString() const{ /* concatenate elements of list with space */ // TODO: concatenated without spaces only if all elements are single characters. // (Is it an official bug? (or feature?)) string ret; for(int i=0;i<data.size();i++){ if (i > 0) ret += ' '; ret += data[i].asString(); } return ret; } int itemNumOfList(const Var &item) const{ auto itr = find(data.begin(), data.end(), item); if (itr == data.end()) return 0; return 1 + (int)(itr - data.begin()); /* index: 1-origined */ } friend ostream& operator << (ostream& os, const VarList& p); }; ostream& operator << (ostream& os, const VarList& p){ os << p.asString(); return os; } long double randUniform(const long double x, const long double y){ if (x > y) return randUniform(y, x); if (floor(x) == x && floor(y) == y){ ll xi = (ll)round(x), yi = (ll)round(y); return xi + rand() % (yi - xi + 1); }else{ return x + (y - x) * (0.0 + rand()) / RAND_MAX; } } Var buf_answer; // for "answer" // ============================= Scripts ============================= // variable declaration Var var_a; Var var_b; Var var_c; Var var_n; Var var_test(0); // list declaration // prototype declaration of functions int main(); // contents of functions int main(){ var_test = Var(0); var_n = Var(1); while (!(var_b < (var_c * var_n))){ if ((((var_a < (var_c * var_n)) || (var_a == (var_c * var_n))) && ((var_b > (var_c * var_n)) || (var_b == (var_c * var_n))))){ cout << (var_c * var_n) << endl; var_test = Var(1); } else { var_n += Var(1); } } if ((var_test == Var(1))){ } else { cout << Var(-1) << endl; } return 0; }
- inoking
-
Scratcher
1000+ posts
Scratch以外のプログラミング言語やってる人交流場
エラーメッセージも貼ってください。
追記:
「Sb3→C++」とは自動で変換されたのですか?
追記:
「Sb3→C++」とは自動で変換されたのですか?
Last edited by inoking (Sept. 26, 2021 13:58:37)
- tsumuri3
-
Scratcher
1000+ posts
Scratch以外のプログラミング言語やってる人交流場
AtCoder初なもので…エラーメッセージの場所教えてください。
「Sb3→C++」とは自動で変換されたのですか?jsonからc++にしてくれるものが用意されています。
- abee
-
Scratcher
1000+ posts
Scratch以外のプログラミング言語やってる人交流場
もし、ブラウザーのプラグインで変換したなら、ここでは答えられないので、その作者の人に聞くことをお勧めします。
- tsumuri3
-
Scratcher
1000+ posts
Scratch以外のプログラミング言語やってる人交流場
分かりました。
追記:コンパイルエラーではないため、エラーメッセージはありませんでした。
あ、Scratchで公開するので、アルゴリズムそのものが変か見て頂けますか?
追記:コンパイルエラーではないため、エラーメッセージはありませんでした。
あ、Scratchで公開するので、アルゴリズムそのものが変か見て頂けますか?
Last edited by tsumuri3 (Sept. 26, 2021 14:03:28)
- inoking
-
Scratcher
1000+ posts
Scratch以外のプログラミング言語やってる人交流場
Scratchで公開するので、アルゴリズムそのものが変か見て頂けますか?main() をざっと見た感じ、
var_a, var_b, var_c が初期化されてないように見えるのと(コンストラクタで自動設定される?)
1つ見つかった時点で終了すればいいのを続行してしまっているように見えます(無駄)。
- inoking
-
Scratcher
1000+ posts
Scratch以外のプログラミング言語やってる人交流場
break文(?)でしたっけ?で抜けられるんですよね…そうですが
自動変換されたものなら変換元を変えるべきかと思います。
- itta611
-
Scratcher
100+ posts
Scratch以外のプログラミング言語やってる人交流場
ループを使うなら、
では毎回nを増やさないとだめだと思います。
ぜひ模範解答もみてください。
https://atcoder.jp/contests/abc220/editorial/2680
もし <...> ならではなく、「まで繰り返す」
...
でなければ
[n v] を (1) ずつ変える
end
では毎回nを増やさないとだめだと思います。
ぜひ模範解答もみてください。
https://atcoder.jp/contests/abc220/editorial/2680
- Poteto143
-
Scratcher
1000+ posts
Scratch以外のプログラミング言語やってる人交流場
Pythonで解くことができました。
与えられたAからBまでの数字を一つずつひたすら
僕の提出: https://atcoder.jp/contests/abc220/submissions/26181204
追記: 提出したコードがCE(コンパイルエラー)になった時は、提出リストの右の「詳細」でエラー内容を確認できます。
tsumuri3さんの今回の提出であればこれです。
与えられたAからBまでの数字を一つずつひたすら
<((数字) を (C) で割った余り) = (0)>に通していけばできそうです。(与えられるAとBも1000までと大きくないのでループ時間を考える必要は無い)
僕の提出: https://atcoder.jp/contests/abc220/submissions/26181204
追記: 提出したコードがCE(コンパイルエラー)になった時は、提出リストの右の「詳細」でエラー内容を確認できます。
tsumuri3さんの今回の提出であればこれです。
Last edited by Poteto143 (Sept. 27, 2021 01:15:24)
- itta611
-
Scratcher
100+ posts
Scratch以外のプログラミング言語やってる人交流場
ちなみに、A問題はループを組まなくても解けるようになっています。
https://atcoder.jp/contests/abc220/submissions/26132539
https://atcoder.jp/contests/abc220/submissions/26132539
- mikan__s
-
Scratcher
71 posts
Scratch以外のプログラミング言語やってる人交流場
僕はjavascriptをし始めましたまだ文字を書くくらいしかできないんですけどね…
HTMLと混ぜてしています。あと、Visual Studio Codeで編集しています。
Bracketsでしようと思いましたが、サポートが終了するようでした(;'∀')
HTMLと混ぜてしています。あと、Visual Studio Codeで編集しています。
Bracketsでしようと思いましたが、サポートが終了するようでした(;'∀')