プログラミング・開発

全169558件中261~280件表示
  • コード(Python)の解説をして頂きたいです

    このコードはスペースが2つ以上ある場合スペースを一つだけにする、そして文の最初と最後にスペースがあった場合そのスペースを消すというコードだということは理解出来たのですが、flgはなんの略なのかということと、ans = ans[1:] if ans[0] == ' ' else ans ans = ans[:-1] if ans[-1] == ' ' else ans このコードのelse ansはどのような働きをしているのか分かりません。 もし宜しければ解説をして頂きたいです。 def removeExtraSpaces(theString): ans = '' flg = True for s in theString: if s == ' ': if flg: ans += s flg = False continue flg = True ans += s ans = ans[1:] if ans[0] == ' ' else ans ans = ans[:-1] if ans[-1] == ' ' else ans return ans

  • Pythonのコードの解説をお願いします

    このコードはスペースが2つ以上ある場合スペースを一つだけにする、そして文の最初と最後にスペースがあった場合そのスペースを消すというものだとういうことは理解出来たのですが、なんでこういうコードを書いたぬぬかついんのか、 def removeExtraSpaces(theString): ans = '' flg = True for s in theString: if s == ' ': if flg: ans += s flg = False continue flg = True ans += s ans = ans[1:] if ans[0] == ' ' else ans ans = ans[:-1] if ans[-1] == ' ' else ans return ans これを解説して

  • Powershellのforのコードエラーについて

    過去に教えてもらったPowershellでExcelにデータを書き込むため2次元配列を使う方法についてターミナルで実行すると下記のようになります PS C:\Users\sakura> $excel = New-Object -ComObject Excel.Application; PS C:\Users\sakura> $excel.Visible = $true; PS C:\Users\sakura> $book = $excel.Workbooks.Add(); PS C:\Users\sakura> $sheet = $excel.Worksheets.Item(1); PS C:\Users\sakura> $array1 = ("果物","リンゴ" ,"ミカン", "バナナ","ぶどう") PS C:\Users\sakura> $array2 = ("個数","10", "20","5","8") PS C:\Users\sakura> $array3 = ("売上","1500", "2000","5000","300") PS C:\Users\sakura> $i = ((gv).Name -match "^array\d+$").Count PS C:\Users\sakura> $j = $array1.Length PS C:\Users\sakura> $arr = New-Object "object[,]" $i,$j PS C:\Users\sakura> $c = for($a=1;$a -le $i;$a++){for($b=0;$b -le $j;$b++){"`$arr[$($a-1),$($b)] = `$array$a[$b]"}}; PS C:\Users\sakura> $c | iex; OperationStopped: Index was outside the bounds of the array. OperationStopped: Index was outside the bounds of the array. OperationStopped: Index was outside the bounds of the array. PS C:\Users\sakura> $range = $sheet.Range("B2") PS C:\Users\sakura> $range.Resize($i, $j) = $arr PS C:\Users\sakura> $excel = $null; PS C:\Users\sakura> [GC]::Collect(); 別のアプリからコマンドラインで実行すればExcelに正しく書き込まれていたので気が付かなかったのですが今回PowershellでExcelの別操作をターミナルから試していた際ようやく気がついたのです。 何故 OperationStopped: Index was outside the bounds of the array. エラーとなるのでしょうかお教えください。

  • pythonの問題を解くのを助けていただきたいです

    スペースが2つ以上ある場合スペースを一つだけにする、そして文の最初と最後にスペースがあった場合そのスペースを消すというコードをこのコードをベースに書き換えていただくことは可能でしょうか? def removeExtraSpaces(theString): outSt = "" foundExtraSpaces = False for ch in theString: if ch = " ": foundExtraSpaces = True elif foundExtraSpaces == True: outSt += ch return outSt print(removeExtraSpaces(" Hello Joe ")) #この場合”Hello Joe”と出力されるはずです。

  • C言語について。

    すみません。待ち行列と緩衝器は根本的に違うものですよね?バッファとスプーラの違いです。教えて頂けると幸いです。

  • Javaのパッケージについて初歩的な質問です

    Javaのパッケージについて質問です このコードの1番最後のZenhanクラスのdoTogameメソッドを呼び出しているところで, パッケージ化していてimportされていないのに クラス名.メソッド名でエラーなしで処理できるのはなぜですか? 同じパッケージ名だからだですか? mainメソッドでimportしてるからですか?教えてください

  • C言語について。

    このコードを教えてください。よろしくお願いします。

  • c言語 行列の積に関して

    <問>  4行3列の行列aと3行4列の行列bの積を、4行4列の行列cに格納する関数を作成せよ。  void mat_mul(const int a[4][3], const int b[3][4], int c[4][4]) 入門レベルのスキルしかありません。 上手く行列の積のプログラムが組めません。 行列の積の計算結果が何も出てきません。 どの様にしたら良いかご指導の程、宜しくお願いします。 <プログラム>  void mat_mul(const int a[4][3], const int b[3][4], int c[4][4]) { int i, j, k; for (i = 0; i < 4; k++) { for (j = 0; j < 4; i++) for (k = 0; k < 3; j++) c[i][j] = c[i][j] + (a[i][k] * b[k][j]); } } void mat_print(const int m[4][4]) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) printf("%4d", m[i][j]); putchar('\n'); } } int main(void) { int i, j ,k; int tensu1[4][3]; int tensu2[3][4]; int seki[4][4]; for(i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { scanf("%d", &tensu1[i][j]); } putchar('\n'); } for(i = 0; i < 3; i++) { for(j = 0; j < 4; j++){ scanf("%d", &tensu2[i][j]); } putchar('\n'); } putchar('\n'); mat_mul(tensu1, tensu2, seki); puts("行列の積"); mat_print(seki); return 0; }  

  • matter.jsのイベントについて教えてください

    いろいろなサイトのサンプルコードを参考にさせていただきながら、matter.jsを使って物理エンジンでの表現を勉強してます。なんとか、20個のボールを生成し、それぞれにラベルで番号をふりました。そのボそのボールをクリックして、どのボールをタッチしたのかをalertで表示させようとしているのですが、以下のコードでうまくいきません。どのようにすればよいでしょうか? <!doctype html> <html> <head> <meta charset="utf-8"> <title>matter.js demo</title> <script src="matter.js"></script> </head> <body> <div id="matter"></div> <script> const engWidth = 680; const engHeight = 400; const wall = 10; const ball = 20; var ballSize = 20; var objs = []; var engine = Matter.Engine.create(document.getElementById("matter"), { render: { options: { wireframes: false, width: engWidth, height: engHeight, background: "rgba(0, 0, 0, 1)" } } }); objs.push(Matter.Bodies.rectangle(engWidth/2, wall/2, engWidth, wall, {isStatic: true})); objs.push(Matter.Bodies.rectangle(engWidth-wall/2, engHeight/2, wall, engHeight, {isStatic: true})); objs.push(Matter.Bodies.rectangle(engWidth/2, engHeight-wall/2, engWidth, wall, {isStatic: true})); objs.push(Matter.Bodies.rectangle(wall/2, engHeight/2, wall, engHeight, {isStatic: true})); for (var i = 0; i < ball; i++) { var x = Math.random()*engWidth; var y = Math.random()*engHeight; // ボールに番号のラベルをつける objs.push(Matter.Bodies.circle(x, y, ballSize, { label: i, render:{ fillStyle: "#FFFFFF", } })); } Matter.World.add(engine.world, objs); var MouseConstraint = Matter.MouseConstraint; // マウスドラッグではなく、マウスクリックのイベントを設定する var mouseclick = MouseConstraint.create(engine, { element: document.getElementById("matter").childNodes[0], constraint: { stiffness: 0.2, render: { visible: false } } }); Matter.World.add(engine.world, mouseclick); // マウスクリックしたボールの番号をalertで表示する Matter.Events.on(mouseclick, 'mousedown', function(e) { alert("You clicked on ball number " + e.body.label); }); Matter.Engine.run(engine); </script> </body> </html>

  • pythonの問題ー解き方を教えて頂きたいです。

    プログラムのコードとどう考えればいいのかを教えていただきたいです。 言語はpythonです。 よろしくお願いします。 Write a function wheelOfFortune(letter, phrase) that plays one guess of the a letter within a phrase. The letter is a single character (that may be upper or lower case). The phrase is a string that is of any length with upper and lower case letters. The function should ignore the case of either the letter or the characters in the phrase. The function prints out the following messages: Example: wheelOfFortune(‘a’, ‘Hello World’) Sorry, there is no "a" Example: wheelOfFortune(‘w’, ‘Hello World’) There was 1 w found Found at position 6 Example: wheelOfFortune(‘L’, ‘Hello World’) There were 3 l's found Found at position 2 Found at position 3 Found at position 9 NOTE: When you print out the first line of how many letters are found, you should print out the letter in lower case always.

  • pythonの問題ー解き方を教えて頂きたいです。

    プログラムのコードとどう考えればいいのかを教えていただきたいです。 言語はpythonです。 よろしくお願いします。 Write a function called genAvg(numList, precision) that takes in a list numbers and finds the average of the numbers. It will then return a string that says something like: The average is 1.234 The output format of the average is specified by the precision parameter that is given to the function. The parameter defines how many digits to the right of the decimal place to round to. So, if the precision is 2, then the output format will round to the hundredths. This parameter will be an integer greater or equal to 0. Use the .format method of strings to make this output string. You may need to create an initial string with some string concatenation operations before using the .format method since the precision is not a fixed value. Example: genAvg([1,2,5], 4) will return the string The average is 2.6667

  • C言語について

    C言語の問題なのですか、作成したのですが内容がわからないです。テキストを読んでも解説が書いていないので、出来ればどなたか簡単な解説でも教えて頂けるとありがたい。 〈7-3〉 #include <stdio.h> int main(void) { int i, j; long kuku[9][9]; // 九九の値の代入処理を記述 for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { kuku[i][j] = (i + 1) * (j + 1); } } ///////////////////////////////////// // 九九の表示部(ここは変更しないこと) for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { printf(" %2d", kuku[i][j]); } printf("\n"); } return 0; }

  • C言語について

    C言語の問題なのですか、作成したのですが内容がわからないです。テキストを読んでも解説が書いていないので、出来ればどなたか簡単な解説でも教えて頂けるとありがたい。 〈コード〉 #include <stdio.h> int main(void) { short point[] = {234, 819, 18, -6492, 795, 20302, 2431, 9029, 0, -28009}; // 定義と逆順に値を表示する for (int i = sizeof(point) / sizeof(point[0]) - 1; i >= 0; i--) { //sizeofで配列要素数を算出 printf("%d\n", point[i]); } return 0; }

  • matter.jsについて教えてください。

    いろいろなサイトのサンプルコードを参考にさせていただきながら、matter.jsを使って物理エンジンでの表現を勉強してます。なんとか、10個のボールを生成し、そのボールを掴んで移動するところまではできました。ボールを掴んで移動させるのではなく、10個を区別して、どのボールをタッチしたのかを表示させていのですが、どのようにすればよいでしょうか? <!doctype html> <html> <head> <meta charset="utf-8"> <title>matter.js demo</title> <script src="matter.js"></script> </head> <body> <div id="matter"></div> <script> const engWidth = 680; const engHeight = 400; const wall = 10; const ball = 20; var ballSize = 20; var objs = []; var engine = Matter.Engine.create(document.getElementById("matter"), { render: { options: { wireframes: false, width: engWidth, height: engHeight, background: "rgba(0, 0, 0, 1)" } } }); objs.push(Matter.Bodies.rectangle(engWidth/2, wall/2, engWidth, wall, {isStatic: true})); objs.push(Matter.Bodies.rectangle(engWidth-wall/2, engHeight/2, wall, engHeight, {isStatic: true})); objs.push(Matter.Bodies.rectangle(engWidth/2, engHeight-wall/2, engWidth, wall, {isStatic: true})); objs.push(Matter.Bodies.rectangle(wall/2, engHeight/2, wall, engHeight, {isStatic: true})); for (var i = 0; i < ball; i++) { var x = Math.random()*engWidth; var y = Math.random()*engHeight; objs.push(Matter.Bodies.circle(x, y, ballSize, { render:{ fillStyle: "#FFFFFF"} })); } Matter.World.add(engine.world, objs); var MouseConstraint = Matter.MouseConstraint; var mousedrag = MouseConstraint.create(engine, { element: document.getElementById("matter").childNodes[0], }); Matter.World.add(engine.world, mousedrag); Matter.Engine.run(engine); </script> </body> </html>

  • スマートフォンカメラ 文字を認識

    倉庫内で作業をしています。特定のの文字をスマートフォンのカメラで探すアプリがあれば教えて下さい。 宜しくお願い致します。

  • C言語のコードについて

    C言語の問題なのですか、作成したのですが内容がわからないです。 コードをわかりやすく解説していただけると嬉しいです。 #include <stdio.h> void printBinary(unsigned char num) { int i ; /*①上位ビットから順に表示する*/ for(i = 7 ; i >= 0; i--) { /*②シフトとマスクを使用しています。*/ printf("%d", (num>>i) &0x01 ); } printf("\n"); } int main(void) { unsigned char num1 = 0xD2;/*11010010*/ unsigned char num2 = 0x5E;/*01011110*/ printf("0xD2 : "); printBinary(num1); printf("0x5E : "); printBinary(num2); return 0; }

  • EXCEL(VBA)について

    EXCEL(VBA)でフォーム外をクリックしたらそのフォームを閉じる事は可能でしょうか? ご教授をお願い致します。

  • Mayumi3 翻訳機 充電口 端子割れ

    こちら端子で代用できますか? https://ja.aliexpress.com/item/1005001999879185.html?src=google&src=google&albch=shopping&acnt=494-037-6276&slnk=&plac=&mtctp=&albbt=Google_7_shopping&albagn=888888&isSmbAutoCall=false&needSmbHouyi=false&albcp=19213787740&albag=&trgt=&crea=ja1005001999879185&netw=x&device=c&albpg=&albpd=ja1005001999879185&gad_source=1&gclid=CjwKCAiAvJarBhA1EiwAGgZl0OoydFS4tdr3EgbrTi92IWKkKLhAhtzU7dgZM0Xno-auXU9G_s-EwxoCiaQQAvD_BwE&gclsrc=aw.ds&aff_fcid=50ab671a54b94088a70742945ec12826-1701176291886-08858-UneMJZVf&aff_fsk=UneMJZVf&aff_platform=aaf&sk=UneMJZVf&aff_trace_key=50ab671a54b94088a70742945ec12826-1701176291886-08858-UneMJZVf&terminal_id=359cb3982bf842f083c9eb1a24e20c12&afSmartRedirect=y

  • unityのaddressablesのkey設定

    unityでゲーム開発をしています。先日Resource.LoadからUnityの機能であるAddressablesを使用したいと思いファイル構造などを設定したのですが、プログラムで読み込むことができませんでした。コードを確認していただいたところ特に問題は見当たらないと言われkeyの設定を見直してくださいと言われました。ですが、keyの設定方法がうまく分からず困っています。もし分かる方がいらっしゃりましたらお願いします。また読み込み部分のコードを画像添付するのでもし問題があればお伝えください。 unityのバージョンは2022.3.13f1、Addressablesのバージョンは1.21.19です。 エラーログ: UnityEngine.AddressableAssets.InvalidKeyException: Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown. No Location found for Key=Txt

  • チャットでgifアイコンを使うにはどうすれば良いか

    https://netroom.co.jp このサイトでgifアイコンを使ってる人がいました。 どうすればgifアイコンを使えるでしようか? 回答よろしくお願いします。