include
int main()
{
std::cout << “Hello, World!\n”;
}
int main()
{
std::cout << “Hello, World!\n”;
}
fname = “Taro”
lname = “Yamada”
age = 32
separator = “=-“
print(separator * 10)
print(“I am {}{},{} years old!”.format(fname, lname,age))
print(f” {fname}{lname},{age} years old!”)
print(separator * 10)
‘use strict’;
{
function printNumberTwice(num: number): void {
console.log(num);
console.log(num);
}
function printStringTwice(str: string): void {
console.log(str);
console.log(str);
}
function printTwice(value: T): void{
console.log(value);
console.log(value);
}
printTwice(10);
printTwice(‘OK’);
}
‘use strict’;
{
let keyword: string | number | boolean;
keyword = ‘milk’;
keyword = 50;
keyword = true;
}
import requests
from bs4 import BeautifulSoup
def crawl(url, max_depth=2):
if max_depth < 0:
return
try:
response = requests.get(url)
content = response.content
soup = BeautifulSoup(content, ‘html.parser’)
links = set()
for link in soup.find_all(‘a’):
href = link.get(‘href’)
if href and href.startswith(‘http’):
links.add(href)
print(f”Found {len(links)} links at {url}”)
for link in links:
crawl(link, max_depth – 1)
except requests.RequestException as e:
print(f”Error during requests to {url} : {str(e)}”)
# 使用例
start_url = “https://b.hatena.ne.jp/” # スタートするURL
crawl(start_url, max_depth=2) # 深さ2でクロール
interface IPoint
{
int Px
{
get; set;
}
int Py
{
get; set;
}
}
class ReversePoint : IPoint
{
int x;
int y;
public ReversePoint(int x, int y)
{
this.x = x;
this.y = y;
}
public int Px
{
get { return -x; }
set { x = value; }
}
// Implementing Py similarly to Px
public int Py
{
get { return -y; } // Return the negative of y
set { y = value; } // Set y directly
}
}
class MainClass
{
public static void DisplayPoint( IPoint point)
{
Console.WriteLine(“x={0},y={1}”, point.Px, point.Py);
}
static void Main()
{
ReversePoint p1 = new ReversePoint(-12, -300);
Console.WriteLine(p1.Px);
Console.WriteLine(p1.Py);
ReversePoint p2 = new ReversePoint(12, 300);
//プロパティの参照
DisplayPoint(p2);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float moveSpeed;
public LayerMask solidObjectsLayer;
public LayerMask grassLayer;
private bool isMoving;
private Vector2 input;
private Animator animator;
private void Awake()
{
animator = GetComponent<Animator>();
}
private void Update()
{
if (!isMoving)
{
input.x = Input.GetAxisRaw("Horizontal");
input.y = Input.GetAxisRaw("Vertical");
//remove diagonal movement
if (input.x != 0) input.y = 0;
if(input != Vector2.zero)
{
animator.SetFloat("moveX", input.x);
animator.SetFloat("moveY", input.y);
var targetPos = transform.position;
targetPos.x += input.x;
targetPos.y += input.y;
if(IsWalkable(targetPos))
StartCoroutine(Move(targetPos));
}
}
animator.SetBool("isMoving", isMoving);
}
IEnumerator Move(Vector3 targetPos)
{
isMoving = true;
while ((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon)
{
transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);
yield return null;
}
transform.position = targetPos; // 目標位置に合わせて最終位置を設定
isMoving = false;
CheckForEncounters();
}
private bool IsWalkable(Vector3 tagetPos)
{
if(Physics2D.OverlapCircle(tagetPos, 0.2f, solidObjectsLayer) != null)
{
return false;
}
return true;
}
private void CheckForEncounters()
{
if(Physics2D.OverlapCircle(transform.position, 0.2f, grassLayer) != null)
{
if(Random.Range(1, 101) <= 10)
{
Debug.Log("野生のポケモンに遭遇した");
}
}
}
PlayerController.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = “ポケモン”, menuName = “ポケモン/新しいポケモンを作成する”)]
public class PokemonBase : ScriptableObject
{
[SerializeField] string name;
[TextArea]
[SerializeField] string description;
[SerializeField] Sprite frontSprite;
[SerializeField] Sprite backSprite;
[SerializeField] PokemonType type1;
[SerializeField] PokemonType type2;
//Base Stats
[SerializeField] int maxHp;
[SerializeField] int attack;
[SerializeField] int defense;
[SerializeField] int spAttack;
[SerializeField] int spDefense;
[SerializeField] int speed;
}
public enum PokemonType
{
None,
Normal,
Fire,
Water,
Electric,
Grass,
Ice,
Fighting,
Poison,
Ground,
Flying,
Psychic,
Bug,
Rock,
Ghost,
Dragon
}
PokemonBase
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Talk : MonoBehaviour
{
public GameObject panel;
public Text txt;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider col)
{
panel.SetActive(true);
}
}
dotinstall:~ $ ls
dotinstall:~ $ touch index.html
dotinstall:~ $ ls -l
total 0
-rw-r–r– 1 dotinsta wheel 0 Sep 8 21:06 index.html
dotinstall:~ $ rm -index.html
rm: unrecognized option: n
BusyBox v1.31.1 () multi-call binary.
Usage: rm [-irf] FILE…
Remove (unlink) FILEs
-i Always prompt before removing
-f Never prompt
-R,-r Recurse
dotinstall:~ $ ls
index.html
dotinstall:~ $ rm – index.html
rm: can’t remove ‘-‘: No such file or directory
dotinstall:~ $ rm – index.html
rm: can’t remove ‘-‘: No such file or directory
rm: can’t remove ‘index.html’: No such file or directory
dotinstall:~ $ ls
dotinstall:~ $
using namespace std;
int main()
{
cout << “9 / 2 = ” << 9 / 2 << endl;
cout << “9 % 2 = ” << 9 % 2 << endl;
cout << “2 + 2 * 4 = ” << 2 + 2 * 4 << endl;
cout << “(1 – 5) / 2 = ” << (1 – 5) / 2 << endl;
return 0;
}