自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 资源 (1)
  • 收藏
  • 关注

原创 clj 10以下的自然数中,属于3或者5的倍数的有3,5,6和9,它们之和是23.找出1000以下的自然数中,属于3或者5的倍数的数字之和

第一种方法(reduce + (set (concat (range 0 1000 3) (range 0 1000 5))))第二种方法(defn sb [n] (reduce + (for [x (range n) :when (or (= (mod x 3) 0) (= (mod x 5) 0))] x)))(sb 1000)...

2021-11-20 09:18:35 207

原创 (更新后的解法)允许并列的排名

#include "stdio.h"void main(){ int N,m,i,x,d=0,j,temp; int a[100]; scanf("%d",&N); for(i=0;i<N;i++) scanf("%d",&a[i]); scanf("%d",&m); for(i=0;i<N-1;i++) { for(j=0;j<N-1-i;j++) { if(a[j]<a[j+1]) { .

2021-11-18 20:36:44 1965 4

原创 允许并列的排名(维克特利奥特曼,这位作者,你要的解答来了)

#include<bits/stdc++.h>using namespace std;int a,b[1000],c;int main(){ cin>>a; for(int i=1;i<=a;i++) cin>>b[i]; cin>>c; for(int i=1;i<=a;i++) for(int j=i;j<=a;j++) if(b[i]<b[j]) swap(b[i],b[j]); for(.

2021-11-17 19:45:23 556 12

原创 html 制作一个有趣的小网站

!DOCTYPE html><html> <head> <meta charset="utf-8"> <title></title> </head> <body> <div id="yang" style="font font-size:15px;color:brown;">请为文字选择颜色和字号</div> ...

2021-11-17 19:36:19 2625

原创 clj 定义一个字符串变量为 i love you, my baby boy and my baby girl输出里面单词出现的次数,并按从次数多到少排序采用2种方法:允许使用frequenc

(def z "i love you, my baby boy and my baby girl")(sort-by val > (reduce #(assoc %1 %2 (inc (%1 %2 0))) {} (re-seq #"\w+" z)))(sort-by val > (frequencies (re-seq #"\w+" z)))

2021-11-14 11:20:19 81 1

原创 clj 写代码,去除重复的值,保留一个,能达到如下效果;;[“a“ “a“ “zm“ “zm“ “zm“ 1 2 3 3 3] => [“a“ “zm“ 1 2 3]

(into [] (map first (partition-by identity ["a" "a" "zm" "zm" "zm" 1 2 3 3 3])))

2021-11-14 11:18:16 198 2

原创 clj 定义一个原子向量,初始为空 brothers 将你们几兄弟加入到brothers中,每个兄弟用一个map映射表来表示,有name,age

(def brothers (atom {}))@brothers(swap! brothers assoc 1 {:id 1 :name "wrl" :age 10} 2 {:id 2 :name "wrj" :age 9} 3 {:id 3 :name "zrj" :age 9} 4 {:id 4 :name "wrp" :age 12})

2021-11-13 16:08:36 179

原创 clj 将字符串 “a,b,c,d“ 转换为 {:A a1 :B b1 :C c1}

(def s "a,b,c,d")(let [vs (str/split s #",") ks (map #(keyword (str/upper-case %)) vs) vs1 (map #(str % 1) vs) ] (dissoc (zipmap ks vs1) :D))

2021-11-13 16:02:42 673

原创 clj 小A 和 小B 在玩猜数字。小B 每次从 1, 2, 3 中随机选择一个,小A 每次也从 1, 2, 3 中选择一个猜。他们一共进行三次这个游戏,请返回 小A 猜对了几次?输入的guess

第一种解法(defn game [guess answer] (count (for [i (range 3) :when (= (guess i) (answer i))] i)))第二种解法(defn game1 [guess answer] (->> (map = guess answer) (filter true?) (count )))...

2021-10-30 20:30:33 1652 1

原创 clj 编写一个函数two-sum 求出两数之和给定一个整数数组 nums和一个整数目标值target请你在该数组中找出和为目标值 target 的那 两个 整数并返回它们的数组下标。

(defn two-sum [nums targer] (let [length (count nums)] (first (for [i (range 0 length) j (range 0 length) :when (and (not= i j) (= targer (+ (nums i) (nums j)))) ] [i j] )).

2021-10-29 21:28:58 210

原创 C++ 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。

#include<stdio.h> int main() { int nums[] = {2, 7, 11, 15}; int n = 4; int target, i, j; int result[] = {-1, -1}; printf("nums=[%d, %d, %d, %d]\n", nums[0], nums[1], nums[2], nums[3]); printf("请输入目标:"); scanf("%d",.

2021-10-07 18:42:58 3462

原创 clojure clj 将[2 5 4 1 3 6 10 56 89]第7、8个元素减1后,再求和

(->> [2 5 4 1 3 6 10 56 89] (drop 6) (take 2) (map #(- % 1)) (reduce +))

2021-10-06 19:04:16 49

原创 clojure clj随机生成50个整数,这50个整数都在1000以内

第一种解法(take 20 (repeatedly #(rand-int 100)))第二种解法(repeatedly 50 #(rand-int 1000))箭头红(->> (repeatedly #(rand-int 100)) (take 20))

2021-10-06 19:02:39 100

原创 c++ ----列朋波骨

#include <iostream>using namespace std;int main(int argc, char *argv[]){ int i; i=0; i=i+1; i=i+1; i=i+1; i=i+1; i=i+1; cout << i; return 0;}

2021-10-06 11:46:59 272

原创 c++ -----你给它输进什么它就输出什么

#include <iostream>using namespace std;int main(int argc, char *argv[]){ int m; cin >> m << endl; return 0;}

2021-10-06 11:41:45 107

原创 clojure clj 写一个函数remove-dup,去除重复的数,保留一个,能达到如下效果. (remove-dup [1 1 1 3 3 5 7 7 9]) => (1 3 5 7 9)

(map first (partition-by identity [1 1 1 3 3 5 7 7 9]))

2021-10-05 17:35:10 77

原创 c++ 精益求精 —————分数化为小数

#include <iostream>using namespace std;int main(int argc, char *argv[]){ cout << 1/7 << endl; cout << 1.0/7 << endl; cout << (double)1/7 << endl; return 0;}

2021-10-05 17:28:35 210

原创 天安门广场 ————变量、表达式

#include <iostream>using namespace std;int main(int argc, char *argv[]){ int a,b,s; a=880 b=500 s=a*b cout << "天安门广场面积"; cout << s << "平方米"; return 0;}

2021-10-05 17:07:58 306

Learn clojure in Y Minutes.webloc

Learn clojure in Y Minutes

2021-10-30

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除