猫史档案馆


不会写代码

用户:落星者落星者查看:18 回复:15 评论:18 创建时间:2022-07-02T20:17:44


哪位大神可以教教我?


回复

上一页1 页 / 共 1下一页
array_已退array_已退

建议看书,自己翻网上的教程很难学会。

如果是Python的话给你推荐《父与子的编程之旅》,挺有趣的,就是有点厚,有点贵。。。

点赞0


评论


_HHHHHHHHHH__HHHHHHHHHH_

机械作家二号 他可厉害了 她的Q:241608571

点赞0


评论


༺追梦の人༻༺追梦の人༻

代码。。。简单,你要哪个?

 

点赞0


评论


灭剑灭剑

你要Python的还是C++的

点赞0


评论


༺追梦の人༻༺追梦の人༻

print("py代码最简单的输出')

点赞0


评论


༺追梦の人༻༺追梦の人༻

# 这是py代码的单行注释
"""
这是py代码的多行注释
"""

点赞0


评论


༺追梦の人༻༺追梦の人༻

a = 12 直接定义变量并赋值

# 也可以赋值其他的
# a = "字符串"
# a = 3.14 # 浮点数
# ......
print(a)# 结果:12

点赞0


评论


༺追梦の人༻༺追梦の人༻

#include<bits/stdc++.h>
using namespace std;

long long fib1(int n){
    if(n<1)
        return -1;
    else if(n==1||n==2)
            return 1;
        else
            return fib1(n-1)+fib1(n-2);
}

long double fib2(int n){
    long double temp;
    if(n<1)
        return -1;
    long double *a=new long double[n+1];
    a[1]=a[2]=1;
    for(int i=3;i<=n;i++)
    {
        a[i]=a[i-1]+a[i-2];
//        cout<<a[i]<<endl;
    }
    temp=a[n];
    delete []a;
    return temp;
}

long double fib3(int n){
	long double s1,s2;
	if(n<1)
		return -1;
	if(n==1 || n==2)
		return 1;
	s1=1;
	s2=1;
	for(int i=3;i<=n;i++){
		s2=s1+s2;
		s1=s2-s1;
//		cout<<i<<":   "<<s2<<endl;
	}
	return s2;
}

int main(){
    time_t s,e,sumtime;
    int n;
    cin>>n;//10 30 50 100
    s=clock();
    cout<<fixed<<setprecision(0);
//    cout<<"fib("<<n<<")="<<fib1(n)<<endl;
//    cout<<"fib("<<n<<")="<<fib2(n)<<endl;
    cout<<"fib("<<n<<")="<<fib3(n)<<endl;
    e=clock();
    sumtime=e-s;
    cout<<"time:"<<sumtime<<endl;
    return 0;
}

 

 

 

 

抱歉,我c++多一点

点赞0


评论


我是伊柒我是伊柒

什么语言的代码,看看我能不能教教你

点赞0


评论


吃掉yande吃掉yande

center_image点猫可以直接转代码

点赞0


评论


PYGAME_dhPYGAME_dh

print('hello word')
#打印括号里的内容
import turtle
#导入turtle模块

turtle.bgcolor('black')
#turtle设置背景颜色为黑色*注:括号内为颜色单词或元组
#turtle.bgcolor((0,0,0)) 使用元组设置颜色*注:数字是0到1之间的小数

for i in range(1,9):
    print(i)
#i是一个变量,range是生成函数
#range(1,9)是指1开始生成,到9前面的一位结束

点赞0


评论


氢氧氢氧

B站上面有详细的,别问我怎么知道的,我没卷

点赞0


评论


村民喵.zip村民喵.zip

import time

print(time.ctime())
b1 = float(input('第1个数'))
b2 = float(input('第2个数'))
for __count in range(100000):
    fh = input('运算符号')
    if fh in '+':
        print((b1 + b2))
        print(time.ctime())
        break
    elif fh in '-' :
        print((b1 - b2))
        print(time.ctime())
        break
    elif fh in '*' :
        print((b1 * b2))
        print(time.ctime())
        break
    elif fh in '/' :
        print((b1 / b2))
        print(time.ctime())
        break
    else :
        print('???????????????????????????')
        print(time.ctime())
        continue

 

点赞0


评论


小橙子_小橙子_

你是学哪一种?box3可以点这个链接:欢迎来到Box3!·GitBook(codemao.cn)

点赞0


评论


小橙子_小橙子_

varblue_kill=0; varred_kill=0; vargun=1; vari=0; constmscale=1/16 constn=[-4,-3,-2,-1,0,1,2,3,4] world.onPlayerJoin(({entity})=>{ //设置刚进入游戏的玩家持有金币(coin)数量为0 entity.player.coin=0 //使用第一人称视角 entity.player.cameraMode=Box3CameraMode.FPS; console.log('settingcameramode:',entity.player.cameraMode); }); console.log('fp喵odeenabled'); world.onPlayerJoin(({entity})=>{ entity.player.enable3DCursor=true; }) functionkillZone(pos,radius,fn){//球状AOE if(gun==3){ for(consteofworld.querySelectorAll('*')){//遍历所有实体 constdist=e.position.distance(pos)//计算作用点与当前实体的距离 if(dist<=radius){//当距离小于等于有效作用半径 fn(e,dist)//传递当前实体和距离到回调函数并执行 } } } } for(consteofworld.querySelectorAll('*')){//遍历每个实体 e.enableDamage=true//允许这个实体受伤/喵/复活 } //利用点击事件对点中的实体造成伤害 world.onClick(({entity,clicker})=>{//entity是被点击的实体,clicker是点击了这个实体的玩家 if(entity.isPlayer){//如果被点击的是个玩家实体 world.say(`${clicker.player.name}击中${entity.player.name}`)//显示玩家的名字 i+=1 } else{ world.say(`${clicker.player.name}击中${entity.id}`)//显示实体的id i+=1 } if(i==20){ gun=2 } if(gun==1){ if(Math.random()==0){ hurts=10 } else{ hurts=20 } } if(gun==2){ if(Math.random()==0){ hurts=50 } else{ hurts=100 } } entity.hurt(hurts) killZone() }) console.clear() functionjoinRed(entity){ entity.addTag('red')//加红队标签 entity.player.color.set(1,0,0)//变红 world.say(`${entity.player.name}被分配到红队`) entity.player.spawnPoint.set(108,14,217)//设置红队的出生点在地图的一边 } functionjoinBlue(entity){ entity.addTag('blue')//加蓝队标签 entity.player.color.set(0,0,1)//变蓝 world.say(`${entity.player.name}被分配到蓝队`) entity.player.spawnPoint.set(97,14,24)//设置蓝队的出生点在地图的另一边 } world.onPlayerJoin(({entity})=>{ constred=world.querySelectorAll('.red')//红队玩家列表 constblue=world.querySelectorAll('.blue')//蓝队玩家列表 if(red.length===blue.length){//如果两队人数相同 if(Math.random()<0.5){//随机加入其中一队 joinBlue(entity)//加入蓝队 } else{ joinRed(entity)//加入红队 } } elseif(red.length>blue.length){//如果红队人多 joinBlue(entity)//加入蓝队 } else{ joinRed(entity)//加入红队 } entity.player.forceRespawn()//传送到自己队伍的出生点 entity.enableDamage=true//允许玩家受伤 entity.score=0//玩家初始得分为0 entity.onDie(async({attacker})=>{ letattackerTeam=teamName(attacker)//对手的队名 letmyTeam=teamName(entity)//玩家的队名 world.say(`[${attackerTeam}]${attacker.player.name}击败了[${myTeam}]${entity.player.name}`) attacker.score+=1//当玩家被击败时,给对手加1分 awaitsleep(5)//等待5秒后复活 entity.player.forceRespawn()//满血回到出生点 }) }) functionteamName(entity){ if(entity.hasTag('red')){//如果有红队标签 return'红队' } elseif(entity.hasTag('blue')){//如果有蓝队标签 return'蓝队' } return'未知队伍' } world.onClick(({entity,clicker})=>{ if(//如果攻击者和被击者在不同的队伍,则被击者会受伤 (entity.hasTag('red')&&clicker.hasTag('blue'))||//被击者是红队,攻击者是蓝队 (entity.hasTag('blue')&&clicker.hasTag('red'))//或者被击者是蓝队,攻击者是红队 ){ entity.hurt(10,{attacker:clicker})//被点击者受到10点伤害,并将点击者传递给onDie事件 } }) world.onPress(({entity,button})=>{ if(button==Box3ButtonType.ACTION1){//右键查看自己的分数 entity.player.dialog({ type:Box3DialogType.TEXT, content:`本回合你击败了${entity.score}个对手` }) if(button==Box3ButtonType.ACTION1){ //将摄像机看向地图中心 constlookTarget=newBox3Vector3(63,8,63); //将摄像机的位置置于地图大概中心处,并往上拉升到y轴150处,确保看到完整的地形 constlookEye=newBox3Vector3(63,150,63); //lookUp用来调整相机角度,可以使画面上下左右颠倒。默认值是(0,1,0) //由于视线是俯视,需要确保lookUp与相机视线方向不平行,需修改为(1,0,0)或者(0,0,1) constlookUp=newBox3Vector3(1,0,0) entity.player.dialog({ type:Box3DialogType.TEXT, content:`俯视`, lookEye:lookEye, lookTarget:lookTarget, lookUp:lookUp }) } } })

点赞0


评论