这是在C中反转字符串的简单代码,最后一个printf语句打印相反的顺序,但是在末尾带有问号,而我只想打印反转的字符串而不是问号。如何解决?
#include<stdio.h>
#include<string.h>
int main(){
char new_string[100];
char string[100];
scanf("%s",string);
printf("original_number = %s\n",string);
int i;
int l = strlen(string)-1;
for(i = 0; i<=l; i++){
new_string[i] = string[l-i];
printf("%c\n",new_string[i]);
}
printf("rev_number = %s\n",new_string);
}
Run Code Online (Sandbox Code Playgroud)
输入:abcd
输出:original_number = abcd
d
C
b
一种
rev_number = DCBA?
我正在尝试使用缩放限制在我的游戏中放大和缩小。我正在使用此代码进行滚动和捏合,但我不知道如何限制缩放距离(minzoomlimit 和 maxzoomlimit)。我的意思是,当玩家想要放大时,他可以放大一定距离,而当他想缩小时,他可以放大一定距离。
这是我用来滚动和捏合的代码。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScrollAndPinch : MonoBehaviour
{
#if UNITY_IOS || UNITY_ANDROID
public Camera Camera;
public bool Rotate;
protected Plane Plane;
public float perspectiveZoomSpeed = 0.5f; // The rate of change of the field of view in perspective mode.
public float orthoZoomSpeed = 0.5f;
public Transform Map;
float distance;
float MaxDistance = 37063.57f; /*= new Vector3(-3724.8f, 34576.9f, -4562.5f);*/
float MinDistance = 123302.2f; /*= new Vector3(-18149.0f, 180315.6f, -73023.5f);*/
private void Awake() …Run Code Online (Sandbox Code Playgroud)