プログラミングのお題スレ Part22 (863レス)
前次1-
抽出解除 レス栞

リロード規制です。10分ほどで解除するので、他のブラウザへ避難してください。
207
(1): デフォルトの名無しさん [sage] 2024/02/02(金)10:50:23.49 ID:fEMhv+T7(1/2)
>>206
Rust

fn foo<'a, 'b>(input: &'b [&'a str]) -> Vec<Vec<&'a str>> {
 struct Data<'a> { name: &'a str, rep: usize, coll: Option<Vec<usize }
 let mut data = Vec::<Data>::new();
 let mut map = HashMap::<&str, usize>::new();
 for s in input {
  let (index0, index1) = s.splitn(2, '=')
   .map(|s| match map.get(s) {
    Some(&index) => data[index].rep,
    None => {
     let index = data.len();
     map.insert(s, index);
     data.push(Data { name: s, rep: index, coll: Some(vec![index]), });
     index
    },
   })
   .sorted().tuple_windows().next().unwrap();
  if index0 != index1 {
   let coll0 = data[index0].coll.take().unwrap();
   let coll1 = data[index1].coll.take().unwrap();
   coll1.iter().for_each(|&index| data[index].rep = index0);
   data[index0].coll = Some(itertools::merge(coll0, coll1).collect());
  }
 }
 data.iter().map(|data| &data.coll).flatten()
  .map(|coll| coll.iter().map(|&index| data[index].name).collect()).collect()
}
323: デフォルトの名無しさん [] 2024/04/14(日)18:34:21.49 ID:MHeAinLP(1/2)
解答例

#include <stdio.h>
#include <math.h>

void heron(double, double, double);

int main(void)
{
double a, b, c;
printf("3辺a, b, cを入力せよ ");
scanf("%lf,%lf,%lf", &a, &b, &c);

heron(a, b, c);
}

void heron(double x, double y, double z) // heronの定義
{
double s, t;

s = (x+y+z)*0.5;
t = s*(s-x)*(s-y)*(s-z);

printf("3角形の面積は S=%g\n", sqrt(t));

return;
}
445: デフォルトの名無しさん [sage] 2024/10/12(土)01:39:40.49 ID:OB4ycmPb(3/3)
>>444
while n<=10
j,t=0,0
while j<i
hpy-=rand(1..6)
if hpy<=0
j+=1
t,hpy,hpm=0,1000,5000
next
end
m=0
while m<n
hpm-=rand(1..6)
m+=1
end
if hpm<=0
k+=1
j+=1
t,hpy,hpm=0,1000,5000
next
end
t+=1
end
puts "サイコロ#{n}個で#{i}戦#{k}勝"
k,hpy,hpm=0,1000,5000
n+=1
end
473: デフォルトの名無しさん [sage] 01/04(土)16:26:18.49 ID:kbkaPDs8(1)
>>464 c
https://ideone.com/x7a81M
・strspn使わない
・再帰しない
#include <stdio.h>
int isablang(const char *s) {
const char *t, *u;
for (; *s; s = u) {
if (*s != 'A') return 0; else for (t = s; *t == 'A'; t++);
if (*t != 'B') return 0; else for (u = t; *u == 'B'; u++);
if (t - s != u - t) return 0;
}
return 1;
}
532
(1): 531 [sage] 02/05(水)20:39:11.49 ID:mFRiRIqM(1/2)
>>510 c
https://ideone.com/jeAf1a
・デバッグと若干の整理
599
(1): 9 [sage] 02/13(木)20:24:48.49 ID:UAfabByi(2/3)
数学屋さんかいなw
i,jの「3 4」とか「6 7」は桁の位置をしていしているのではなく数値列の中にある数字を指定するんジャマイカ
とオレは解釈したが
660: デフォルトの名無しさん [] 02/28(金)01:30:55.49 ID:1HSOHgVq(1)
intは処理単位のことなんだけどな
何ビットで表現できるかという意味ではない
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.037s