問題

記事一覧 2026
  • 回答

    Friday, October 23, 2026 in クラス-応用5

    問題 クラス-応用5 の回答ページです. 回答例 int n = 100; // 円の数 PVector[] location = new PVector[n]; // 位置のベクトルの配列 PVector[] velocity = new PVector[n]; // 速度のベクトルの配列 color[] col = new color[n]; // 塗りの色の配列 float[] diameter = new float[n]; // 円の大きさ(直径)の配列 void setup() { …

    続きを読む

  • 回答

    Friday, October 23, 2026 in クラス-応用4

    問題 PVector-応用1 の回答ページです. 回答例 int n = 100; // 円の数 PVector[] positions = new PVector[n]; // 各円の位置 PVector[] velocities = new PVector[n]; // 各円の速度 float[] d = new float[n]; // 各円の直径 void setup() { size(500, 500); noStroke(); for (int i = 0; i < n; …

    続きを読む

  • 回答

    Friday, October 23, 2026 in クラス-基礎6

    問題 PVector-基礎1 の回答ページです. 回答例 1. PVector を使わない場合 float posX, posY, spX, spY; // 円の位置,速度 int d; // 円の直径 void setup() { size(500, 500); noStroke(); // 円の直径をランダムに設定(5~30ピクセル) d = int(random(5, 31)); // 円全体がキャンバス内に収まる範囲で,初期位置をランダムに設定 posX = random(d / …

    続きを読む

  • 回答

    Friday, October 23, 2026 in クラス-発展1

    問題 PVector-発展1 の回答ページです. 回答例 PVector position; // ボールの位置 PVector velocity; // ボールの速度 PVector gravity; // 重力加速度 float d = 40; // ボールの直径 void setup() { size(500, 500); noStroke(); position = new PVector(100, 50); velocity = new PVector(2, 0); gravity = …

    続きを読む

  • 回答

    Wednesday, October 21, 2026 in クラス-応用3

    問題 クラス-応用3 の回答ページです. 回答例 PImage img; void setup() { size(500, 500); img = loadImage("flower.png"); img.resize(500, 500); // 画面サイズと合わせる image(img, 0, 0); img.loadPixels(); noStroke(); for(int y=0; y<height; y+=20){ for(int x=0; x<width; …

    続きを読む

  • 回答

    Wednesday, October 21, 2026 in クラス-応用2

    問題 クラス-応用2 の回答ページです. 回答例 PImage img; void setup() { size(500, 500); img = loadImage("flower.png"); img.resize(500, 500); // 画面サイズと合わせる image(img, 0, 0); img.loadPixels(); noStroke(); for(int y=0; y<height; y+=20){ for(int x=0; x<width; …

    続きを読む

  • 回答

    Wednesday, October 21, 2026 in クラス-応用1

    問題 クラス-応用1 の回答ページです. 回答例 void setup(){ // 大文字と小文字を区別しないように,すべて小文字にする str = str.toLowerCase(); // 記号 , ! . を取り除く String[] ignorelist = {",", "!", "."}; for(int i=0; i<ignorelist.length; i++){ str = str.replace(ignorelist[i], …

    続きを読む

  • 回答

    Wednesday, October 21, 2026 in クラス-基礎5

    問題 クラス-基礎5 の回答ページです. 回答例 PImage img; float w,h; void setup(){ size(400,400); background(255); img = loadImage("flower.png"); img.resize(100,100); } void draw(){ int red = int(random(256)); int green = int(random(256)); int blue = …

    続きを読む

  • 回答

    Wednesday, October 21, 2026 in クラス-基礎4

    問題 クラス-基礎4 の回答ページです. 回答例 PImage img; float w,h; void setup(){ size(800,800); background(255); img = loadImage("flower.png"); w = img.width; h = img.height; image(img,0,0,w,h); } void draw(){ } void mousePressed(){ background(255); …

    続きを読む

  • 回答

    Wednesday, October 21, 2026 in クラス-基礎3

    問題 クラス-基礎3 の回答ページです. 回答例 String str1 = "AABB"; String str2 = "ABAC"; void setup() { int d = 0; for (int i = 0; i < str1.length(); i++) { if (str1.charAt(i) != str2.charAt(i)) { d++; } } println(str1 + "と" + str2 + "のハミン …

    続きを読む