HALF<水题>

题意:

找出n/d=0.5的所有数。输入:test,x(代表n的位数,1<=x<=4).并且n和d的每一个位数不能有重复,也不能是0。
输入:
1
1
输出:
the form 1/2 = 0.5.
the form 2/4 = 0.5.
the form 3/6 = 0.5.
the form 4/8 = 0.5.
the form 6/12 = 0.5.
the form 7/14 = 0.5.
the form 8/16 = 0.5.
the form 9/18 = 0.5.
#include<cstdio>
#include<cmath>
using namespace std;
int main ()
{
    int a[10];
    int t;scanf("%d",&t);
    while(t--){
        int n;scanf("%d",&n);
        int mi=pow(10,n-1);
        int ma=pow(10,n)-1;
        for(int k=mi;k<=ma;k++){
            for(int i=0;i<10;i++) a[i]=0;
            int A=k;
            int B=2*A;
            while(A) a[A%10]++ , A/=10;
            while(B) a[B%10]++ , B/=10;
            int flag=1;
            for(int i=0;i<10;i++) if(a[0]||a[i]>1) flag=0;
            if(flag) printf("the form %d/%d = 0.5.\n",k,2*k);
        }
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段代码应该放在控制person模型移动的代码中,而不是放在person模型或GameView中。通常情况下,控制person模型移动的代码应该是由一个脚本组件来实现的,这个脚本组件可以挂载在person对象上或者GameView对象上。 假设我们将控制person模型移动的代码放在一个名为"PersonController"的脚本组件中,那么完整的实现方式如下: 1.在PersonController脚本组件中定义一个变量来引用GameView对象: ``` public GameObject gameView; ``` 2.在PersonController脚本组件的Start()方法中获取GameView的矩形范围: ``` private Rect gameViewRect; void Start() { gameViewRect = gameView.GetComponent<RectTransform>().rect; } ``` 3.在PersonController脚本组件的Update()方法中控制person模型的移动,并且判断是否超出了GameView的范围: ``` void Update() { Vector3 position = transform.position; float halfWidth = GetComponent<Renderer>().bounds.size.x / 2; float halfHeight = GetComponent<Renderer>().bounds.size.y / 2; if (position.x - halfWidth < gameViewRect.xMin) { position.x = gameViewRect.xMin + halfWidth; } if (position.x + halfWidth > gameViewRect.xMax) { position.x = gameViewRect.xMax - halfWidth; } if (position.y - halfHeight < gameViewRect.yMin) { position.y = gameViewRect.yMin + halfHeight; } if (position.y + halfHeight > gameViewRect.yMax) { position.y = gameViewRect.yMax - halfHeight; } transform.position = position; } ``` 其中,transform表示当前对象的Transform组件,GetComponent<Renderer>()表示获取当前对象的Renderer组件,bounds表示获取Renderer组件的边界信息。这段代码可以确保person模型在移动时不会超出GameView的范围。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值