anonymous No title
Java
package datashori;

public class person1 {

	   private String name ;
	   private int age;
	   private double height;
	   private int shoes ;
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		if(0 <= age ) {
			this.age = age;
			}else {
				System.out.println("おかしいですよ");
			}

		}


	public double getHeight() {
		return height;
	}
	public void setHeight(double height) {
		this.height = height;
	}
	public int getShoes() {
		return shoes;
	}
	public void setShoes(int shoes) {
		this.shoes = shoes;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	public person1(){
		setName("香月");
		setAge(-1);
		setHeight(172.5);
		setShoes(20);
	}

	public void shoesAvarage(int b,int c ){
		  double a;
		  a = (double)b/c;
        System.out.println(a);
		     }


}
anonymous No title
Java
/*
 * (1) 整数の配列 t を引数として受け取り、配列 t の3要素を3辺の長さとする三角形が構成可能か
 *     どうかを判定するメソッド isTriangle を作成せよ。
 *     public static boolean isTriangle(int[] t)
 *
 * (2) 整数の配列 t の配列(2次元配列) tary を引数として受け取り、配列 t の3要素を3辺の
 *     長さとする三角形の面積が最大となる t のインデックスを返却するメソッド maxTriangle
 *     を作成せよ。
 *     public static int maxTriangle(int[][] tary)
 */

class Ex06 {
    static String yourname = "simei"; // 氏名を入力すること

    // 三角形かどうかを判定するメソッド
    public static boolean isTriangle(int[] t) {
        // メソッドのコードを記入



        return false; // 不要な場合は削除
    }

    // 面積が最大の三角形を抽出するメソッド
    public static int maxTriangle(int[][] tary) {
        // メソッドのコードを記入



        return -1; // 不要な場合は削除
    }

    /* 検証 -- 動作確認テストの内容と方法を記述


     */

    /* 考察 -- 調査したこと、考慮したこと、工夫したことを記述


     */

    // メインメソッド(テストプログラム)
    public static void main(String[] args) {
        int[][] tarray = {
                { 7, 5, 3 }, { 4, 6, 5 }, { 4, 4, 7 }, { 2, 5, 8 },
                { 6, 6, 3 }, { 5, 5, 4 }, { 8, 4, 4 }, { 5, 4, 7 },
        };
        System.out.println("Testing isTriangle ...");
        for (int[] t : tarray) {
            System.out.printf("%s %s\n",
                    java.util.Arrays.toString(t), isTriangle(t));
        }
        System.out.println("Testing maxSize ...");
        int k = maxTriangle(tarray);
        System.out.print(k);
        if (k >= 0) {
            System.out.printf(" %s\n",
                    java.util.Arrays.toString(tarray[k]));
        } else {
            System.out.println();
        }
    }
}
anonymous No title
Java
@Override
protected void onCreate(Bundle savedInstanceState) {
    if ( isLogin ) {
        intent = new Intent(this,MainActivity.class);
    } else {
        intent = new Intent(this,LoginActivity.class);
    }
    startActivity(intent);
    finish();
}
anonymous No title
Java
package com.db.java;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/InputServlet")
public class InputServlet extends HttpServlet {
	protected void doPost(
							HttpServletRequest request,
							HttpServletResponse response
						)
						throws
							ServletException,
							IOException
	{
		request.setCharacterEncoding("UTF-8");

		String name = request.getParameter("name");
		String age = request.getParameter("age");

		ManGenerator gen = new ManGenerator(name, age);
		request.setAttribute("human", gen.getHuman());

		RequestDispatcher rd = request.getRequestDispatcher("output.jsp");
		rd.forward(request, response);

	}
}
anonymous No title
Java
#define CALIBRATION_SAMPLES 70  // Number of compass readings to take when calibrating
#define CRB_REG_M_2_5GAUSS 0x60 // CRB_REG_M value for magnetometer +/-2.5 gauss full scale
#define CRA_REG_M_220HZ    0x1C // CRA_REG_M value for magnetometer 220 Hz update rate

void setupCompass()
{
  compass.init();
  compass.enableDefault();
  compass.writeReg(LSM303::CRB_REG_M, CRB_REG_M_2_5GAUSS); // +/- 2.5 gauss sensitivity to hopefully avoid overflow problems
  compass.writeReg(LSM303::CRA_REG_M, CRA_REG_M_220HZ);    // 220 Hz compass update rate
  delay(1000); // 良く分からないが必要
}

void  calibrationCompass()
{
  unsigned int index;
  int motorL, motorR;

  LSM303::vector<int16_t> running_min = {
    32767, 32767, 32767
  }
  , running_max = {
    -32767, -32767, -32767
  };

  motorL = 200;
  motorR = -200;
  motors.setLeftSpeed(motorL);
  motors.setRightSpeed(motorR);

  for (index = 0; index < CALIBRATION_SAMPLES; index ++)
  {
    // Take a reading of the magnetic vector and store it in compass.m
    compass.read();

    running_min.x = min(running_min.x, compass.m.x);
    running_min.y = min(running_min.y, compass.m.y);

    running_max.x = max(running_max.x, compass.m.x);
    running_max.y = max(running_max.y, compass.m.y);

    delay(50);
  }

  motorL = 0;
  motorR = 0;
  motors.setLeftSpeed(motorL);
  motors.setRightSpeed(motorR);

  // Set calibrated values to compass.m_max and compass.m_min
  compass.m_max.x = running_max.x;
  compass.m_max.y = running_max.y;
  compass.m_min.x = running_min.x;
  compass.m_min.y = running_min.y;
}

void CalibrationCompassManual()
{
  compass.m_min.x = 0;
  compass.m_min.y = 0;
  compass.m_max.x = 0;
  compass.m_max.y = 0;
}

template <typename T> float heading(LSM303::vector<T> v)
{
  float x_scaled =  2.0 * (float)(v.x - compass.m_min.x) / ( compass.m_max.x - compass.m_min.x) - 1.0;
  float y_scaled =  2.0 * (float)(v.y - compass.m_min.y) / (compass.m_max.y - compass.m_min.y) - 1.0;

  float angle = atan2(y_scaled, x_scaled) * 180 / M_PI;
  if (angle < 0)
    angle += 360;
  return angle;
}

// Yields the angle difference in degrees between two headings
float relativeHeading(float heading_from, float heading_to)
{
  float relative_heading = heading_to - heading_from;

  // constrain to -180 to 180 degree range
  if (relative_heading > 180)
    relative_heading -= 360;
  if (relative_heading < -180)
    relative_heading += 360;

  return relative_heading;
}

// Average 10 vectors to get a better measurement and help smooth out
// the motors' magnetic interference.
float averageHeading()
{
  LSM303::vector<int32_t> avg = {
    0, 0, 0
  };

  for (int i = 0; i < 10; i ++)
  {
    compass.read();
    avg.x += compass.m.x;
    avg.y += compass.m.y;
  }
  avg.x /= 10.0;
  avg.y /= 10.0;

  // avg is the average measure of the magnetic vector.
  return heading(avg);
}

float averageHeadingLP()
{
  static LSM303::vector<int32_t> avg = {
    0, 0, 0
  };

  compass.read();
  avg.x = 0.2 * compass.m.x + 0.8 * avg.x;
  avg.y = 0.2 * compass.m.y + 0.8 * avg.y ;


  // avg is the average measure of the magnetic vector.
  return heading(avg);
}
anonymous No title
Java
#include <Wire.h>
#include <math.h>
#define COLOR_SENSOR_ADDR  0x39//the I2C address for the color sensor 
#define REG_CTL 0x80
#define REG_TIMING 0x81
#define REG_INT 0x82
#define REG_INT_SOURCE 0x83
#define REG_ID 0x84
#define REG_GAIN 0x87
#define REG_LOW_THRESH_LOW_BYTE 0x88
#define REG_LOW_THRESH_HIGH_BYTE 0x89
#define REG_HIGH_THRESH_LOW_BYTE 0x8A
#define REG_HIGH_THRESH_HIGH_BYTE 0x8B
#define REG_BLOCK_READ 0xCF
#define REG_GREEN_LOW 0xD0
#define REG_GREEN_HIGH 0xD1
#define REG_RED_LOW 0xD2
#define REG_RED_HIGH 0xD3
#define REG_BLUE_LOW 0xD4
#define REG_BLUE_HIGH 0xD5
#define REG_CLEAR_LOW 0xD6
#define REG_CLEAR_HIGH 0xD7
#define CTL_DAT_INIITIATE 0x03
#define CLR_INT 0xE0
//Timing Register
#define SYNC_EDGE 0x40
#define INTEG_MODE_FREE 0x00
#define INTEG_MODE_MANUAL 0x10
#define INTEG_MODE_SYN_SINGLE 0x20
#define INTEG_MODE_SYN_MULTI 0x30

#define INTEG_PARAM_PULSE_1 0x00
#define INTEG_PARAM_PULSE_2 0x01
#define INTEG_PARAM_PULSE_4 0x02
#define INTEG_PARAM_PULSE_8 0x03
//Interrupt Control Register
#define INTR_STOP 40
#define INTR_DISABLE 0x00
#define INTR_LEVEL 0x10
#define INTR_PERSIST_EVERY 0x00
#define INTR_PERSIST_SINGLE 0x01
//Interrupt Souce Register
#define INT_SOURCE_GREEN 0x00
#define INT_SOURCE_RED 0x01
#define INT_SOURCE_BLUE 0x10
#define INT_SOURCE_CLEAR 0x03
//Gain Register
#define GAIN_1 0x00
#define GAIN_4 0x10
#define GAIN_16 0x20
#define GANI_64 0x30
#define PRESCALER_1 0x00
#define PRESCALER_2 0x01
#define PRESCALER_4 0x02
#define PRESCALER_8 0x03
#define PRESCALER_16 0x04
#define PRESCALER_32 0x05
#define PRESCALER_64 0x06

int readingdata[20];
int dataR, dataG, dataB, clr;
int dataR_min, dataG_min, dataB_min;
int dataR_max, dataG_max, dataB_max;


void  calibrationColorSensorWhite()
{
  unsigned long timeInit;
  int count;
  unsigned long red, green, blue;

  motors.setLeftSpeed(70);
  motors.setRightSpeed(70);

  red = 0;
  green = 0;
  blue = 0;
  count = 0;
  timeInit = millis();
  while ( 1 ) {
    readRGB();
    red += dataR;
    green += dataG;
    blue += dataB;
    ++count;

    if ( millis() - timeInit > 3000 )
      break;
  }
  dataR_max = red / count;
  dataG_max = green / count;
  dataB_max = blue / count;

  motors.setLeftSpeed(0);
  motors.setRightSpeed(0);
}

void  calibrationColorSensorBlack()
{
  unsigned long timeInit;
  int count;
  unsigned long red, green, blue;

  motors.setLeftSpeed(70);
  motors.setRightSpeed(70);

  red = 0;
  green = 0;
  blue = 0;
  count = 0;
  timeInit = millis();
  while ( 1 ) {
    readRGB();
    red += dataR;
    green += dataG;
    blue += dataB;
    ++count;

    if ( millis() - timeInit > 3000 )
      break;
  }
  dataR_min = red / count;
  dataG_min = green / count;
  dataB_min = blue / count;

  motors.setLeftSpeed(0);
  motors.setRightSpeed(0);
}

void clearInterrupt()
{
  Wire.beginTransmission(COLOR_SENSOR_ADDR);
  Wire.write(CLR_INT);
  Wire.endTransmission();
}

void readRGB()
{
  Wire.beginTransmission(COLOR_SENSOR_ADDR);
  Wire.write(REG_BLOCK_READ);
  Wire.endTransmission();

  Wire.beginTransmission(COLOR_SENSOR_ADDR);
  Wire.requestFrom(COLOR_SENSOR_ADDR, 8);

  if (8 <= Wire.available())  // if two bytes were received
  {
    for (int i = 0; i < 8; i++)
    {
      readingdata[i] = Wire.read();
      //Serial.println(readingdata[i],BIN);
    }
  }

  dataG = readingdata[1] * 256 + readingdata[0];
  dataR = readingdata[3] * 256 + readingdata[2];
  dataB = readingdata[5] * 256 + readingdata[4];
  clr = readingdata[7] * 256 + readingdata[6];

  red_G = map(dataR, dataR_min, dataR_max, 0, 255);
  green_G = map(dataG, dataG_min, dataG_max, 0, 255);
  blue_G = map(dataB, dataB_min, dataB_max, 0, 255);
  if ( red_G < 0 ) red_G = 0;
  if ( red_G > 255 ) red_G = 255;
  if ( green_G < 0 ) green_G = 0;
  if ( green_G > 255 ) green_G = 255;
  if ( blue_G < 0 ) blue_G = 0;
  if ( blue_G > 255 ) blue_G = 255;
}

void setupColorSensor()
{
  setTimingReg(INTEG_MODE_FREE);//Set trigger mode.Including free mode,manually mode,single synchronizition mode or so.
  setInterruptSourceReg(INT_SOURCE_GREEN); //Set interrupt source
  setInterruptControlReg(INTR_LEVEL | INTR_PERSIST_EVERY); //Set interrupt mode
  setGain(GAIN_1 | PRESCALER_4); //Set gain value and prescaler value
  setEnableADC();//Start ADC of the color sensor
}

void setTimingReg(int x)
{
  Wire.beginTransmission(COLOR_SENSOR_ADDR);
  Wire.write(REG_TIMING);
  Wire.write(x);
  Wire.endTransmission();
  delay(100);
}
void setInterruptSourceReg(int x)
{
  Wire.beginTransmission(COLOR_SENSOR_ADDR);
  Wire.write(REG_INT_SOURCE);
  Wire.write(x);
  Wire.endTransmission();
  delay(100);
}
void setInterruptControlReg(int x)
{
  Wire.beginTransmission(COLOR_SENSOR_ADDR);
  Wire.write(REG_INT);
  Wire.write(x);
  Wire.endTransmission();
  delay(100);
}
void setGain(int x)
{
  Wire.beginTransmission(COLOR_SENSOR_ADDR);
  Wire.write(REG_GAIN);
  Wire.write(x);
  Wire.endTransmission();
}
void setEnableADC()
{
  Wire.beginTransmission(COLOR_SENSOR_ADDR);
  Wire.write(REG_CTL);
  Wire.write(CTL_DAT_INIITIATE);
  Wire.endTransmission();
  delay(100);
}
anonymous No title
Java
#include <Wire.h>
#include <ZumoMotors.h>
#include <Pushbutton.h>
#include <LSM303.h>

ZumoMotors motors;
Pushbutton button(ZUMO_BUTTON);
LSM303 compass;

float red_G, green_G, blue_G; // カラーセンサーで読み取ったRGB値(0-255)
float mx = 0, my = 0, mz = 0;         //compass(-128 - 127)
float ax = 0, ay = 0, az = 0;

int motorR_G, motorL_G;  // 左右のZumoのモータに与える回転力

unsigned long timeInit_G, timeNow_G; //  スタート時間,経過時間

const int buzzerPin = 3;

const int trig = 2;     //TrigピンをArduinoの2番ピンに
const int echo = 4;     //EchoピンをArduinoの4番ピンに
unsigned long interval; //Echo のパルス幅(μs)
const int stop_echo = 60;
float distance;           //距離(cm)

float direction_G;
float now_direction_G;

int mode_G; // タスクのモードを表す状態変数
int mode_T; // zone3のモードを表す状態変数
int color_mode_G = 0;
int pat = 0;

int zone1_flag = 0;

static int count_across = 0;     //交差点をカウントする

int inByte_G;  //リスタート用

int c_fin = 0;

int lane_color = 0;   //0:緑 1:青

unsigned long s_time = 0;


static int r_time = 0;
static int p_time = 0;
static int b_time = 0;
static int g_time = 0;
static int lb_time = 0;
static int d_time = 0;

void linetrace_P_control(int Color_mode)
{
  static float lightMin = 0; // 各自で設定
  static float lightMax = 255;// 各自で設定
  float speed; // パラメーター
  float Kp; // パラメーター
  float lightNow;
  float speedDiff;

  if (Color_mode == 0) { //Green以外のとき

    speed = 90; // パラメーター
    Kp = 2.8; // パラメーター

  } else if (Color_mode == 1) { //Greenのとき

    speed = 70; // パラメーター
    Kp = 4.9; // パラメーター

  }
  else if (Color_mode == 2) { //マゼンダのとき

    speed = 40; // パラメーター
    Kp = 4.9; // パラメーター

  }

  lightNow = (red_G + green_G + blue_G ) / 3.0;

  speedDiff = map(lightNow, lightMin, lightMax, -Kp * speed, Kp * speed);

  motorL_G = speed + speedDiff;
  motorR_G = speed - speedDiff;
}

void linetrace_P_black(int Color_mode)
{
  static float lightMin = 0; // 各自で設定
  static float lightMax = 255;// 各自で設定
  float speed; // パラメーター
  float Kp; // パラメーター
  float lightNow;
  float speedDiff;

  if (Color_mode == 0) { //Green以外のとき

    speed = 250; // パラメーター
    Kp = 2.0; // パラメーター

  } else if (Color_mode == 1) { //Greenのとき

    speed = 70; // パラメーター
    Kp = 4.9; // パラメーター

  }
  else if (Color_mode == 2) { //マゼンダのとき

    speed = 40; // パラメーター
    Kp = 4.9; // パラメーター

  }

  lightNow = (red_G + green_G + blue_G ) / 3.0;

  speedDiff = map(lightNow, lightMin, lightMax, -Kp * speed, Kp * speed);

  motorL_G = speed + speedDiff;
  motorR_G = speed - speedDiff;
}

void task_line()
{
  static int stop_period;
  static unsigned long startTime;   //static変数,時間計測はunsigned long
  char color;
  float lightNow;
  static int done = 0;
  static int count_blue = 0; //緑をカウントする
  static int count_across = 0; //交差点をカウントする
  int buzzer = 0;


  switch ( mode_T ) {
    case 0:  //動作待機中
      Serial.write(5);    //待機中
      motorL_G = 0; //停止
      motorR_G = 0;
      button.waitForButton();
      mode_T = 1;
      if (Serial.available() > 0) {
        if (Serial.read() == 100) { //processingからスタートの合図を受け取った時
          mode_T = 1; //動作開始
        }
      }
      break;

    case 1:               //探索モード
      motorR_G = 100;
      motorL_G = 100;

      /*判定*/
      if ( identify_RGB() == 'R' && r_time == 0 ) { // レッド
        mode_T = 2;
      } else if (identify_RGB() == 'M' && p_time == 0) { // マゼンダ
        mode_T = 3;
      } else if (identify_RGB() == 'B' && b_time == 0) { // ブルー
        mode_T = 4;
      } else if (identify_RGB() == 'D') { // ブラック
        mode_T = 5;
      } else if (identify_RGB() == 'G' && g_time == 0) { // グリーン
        mode_T = 6;
      } else if (identify_RGB() == 'C' && lb_time == 0) { // ライトブルー
        mode_T = 7;
      }
      break;

    case 2:  //レッド
      r_time = 1;
      linetrace_P_control(0);
      if (maintainState(9000) == 1)
      {
        c_fin ++;
        mode_T = 1;
        if (c_fin >= 3)
          mode_T = 8;
      }
      break;

    case 3:  //ピンク
      p_time = 1;
      linetrace_P_control(2);
      if (maintainState(7000) == 1)
      {
        c_fin ++;
        mode_T = 1;
        if (c_fin >= 3)
          mode_T = 8;
      }
      break;

    case 4:  //ブルー
      b_time = 1;
      linetrace_P_control(0);
      if (maintainState(7000) == 1)
      {
        c_fin ++;
        mode_T = 1;
        if (c_fin >= 3)
          mode_T = 8;
      }
      break;

    case 5:  //ブラック
      if (pat == 0)
      {
        motorL_G = 150;
        motorR_G = -150;
        if (maintainState(1500) == 1)
          mode_T = 1;
        pat ++;
      }
      else if (pat == 1)
      {
        motorL_G = 100;
        motorR_G = -100;
        if (maintainState(1500) == 1)
          mode_T = 1;
        pat ++;
      }
      else if (pat == 2)
      {
        motorL_G = 80;
        motorR_G = -80;
        if (maintainState(1500) == 1)
          mode_T = 1;
        pat = 0;
      }
      break;

    case 6:  //グリーン
      g_time = 1;
      linetrace_P_control(1);
      if (maintainState(16000) == 1)
      {
        c_fin ++;
        mode_T = 1;
        if (c_fin >= 3)
          mode_T = 8;
      }
      break;

    case 7:  //ライトブルー
      lb_time = 1;
      linetrace_P_control(0);
      if (maintainState(8000) == 1)
      {
        c_fin ++;
        mode_T = 1;
        if (c_fin >= 3)
          mode_T = 8;
      }
      break;

    case 8:  // 脱出
      motorR_G = 130;
      motorL_G = 130;
      zone1_flag = 1;
      break;
  }
}
anonymous No title
Java
import java.util.Scanner;
public class KuKuhyo {

	int x,y;
	int KuKu[][] = new int[10][10];
	
	Scanner scan = new Scanner(System.in);
	
	public void input() {
		
		for(int i = 0; i <= 9; i++) {
			for(int j = 0; j <= 9; j++) {
				KuKu[i][j] = (i+1)*(j+1);
			}
		}
		
		x = scan.nextInt();
		y = scan.nextInt();
		
		System.out.println(KuKu[x][y]); //(output)
	}
	public static void main(String[] args) {
		KuKuhyo Pro = new KuKuhyo();
		Pro.input();

	}

}
Kohei Arai LeetCode 83 - Remove Duplicates from Sorted List
Java
public ListNode deleteDuplicates(ListNode head) {
	if (head == null) {
		return head;
	}
	ListNode max = head;
	ListNode curr = head;
	
	while (curr != null) {
		if (max.val != curr.val) {
			max.next = curr;
			max = curr;
		}
		curr = curr.next;
	}
	max.next = null;
	
    return head;
}
anonymous No title
Java

プログラム
import java.util.Scanner;
public class program {
 public void input () {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt() ;
int array[][] = new int[10][10];
for(int a = 1; a<10; a++) {
 for(int b = 1; b<10; b++) {
  array[a][b] = a*b;
if(array[a][b]>n) {
break;
}
System.out.print(array[a][b]+" ");
}
System.out.println();
}
}
  public void compute () {
}
 public void output () {
}
public static void main(String [] args) {
 program p = new program ();
 p.input ();
 p.compute ();
 p.output ();
}
}
Don't you submit code?
Submit