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;
}
using System;
struct Simple
{
public int Number;
public string Name;
public Simple(int n,string s)
{
Number = n;
Name = s;
}
}
class MainClass
{
static void Main()
{
Simple s1 = new Simple();
Console.WriteLine(s1.Number);
Console.WriteLine(s1.Name);
Simple s2 = new Simple(1, "testname");
Console.WriteLine(s2.Number);
Console.WriteLine(s2.Name);
Simple ss;
}
}
using System;
namespace array3
{
internal class Program
{
static void Main(string[] args)
{
string[] weekDays =
{ “sun”, “Mon”, “Tue” , “Wed”, “Thu”, “Fri” , “Sat”};
for(int i = 0; i < weekDays.Length; i++)
{
Console.WriteLine(weekDays[i]);
}
foreach(string s in weekDays)
{
Console.WriteLine(s);
}
int[] a = { 1, 2, 3 };
int sum = 0;
for(int i = 0; i < a.Length; i++)
{
sum += a[i];
}
Console.WriteLine(sum);
}
}
}
using System;
namespace array1
{
internal class Program
{
static void Main(string[] args)
{
int[] array = new int[10];
//代入
array[0] = 1;
array[1] = 2;
Console.WriteLine(array[0] + array[1]);
}
}
}
using System;
namespace overflow
{
internal class Program
{
static void Main(string[] args)
{
try
{
short a = short.MaxValue;
Console.WriteLine(a);
a++;
Console.WriteLine(a);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
using System;
namespace exception8
{
internal class Program
{
static void Main(string[] args)
{
try
{
try
{
int[] a = new int[3];
a[0] = 1;
a[5] = 2;
}
catch (Exception)
{
Console.WriteLine("最初の捕捉");
throw;
}
}
catch (Exception e)
{
Console.WriteLine("外側の捕捉");
Console.WriteLine(e.Message);
}
}
}
}
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でクロール