#include <stdio.h>
#include <stdlib.h>
#define f(x) (1 / (x*x+1))
int main(){
double a,b,h,x,y;
printf("Enter a, b, h: ");
scanf(" %lf %lf %lf " , &a, &b, &h);
// I ask for 3 inputs but the programm needs 4 to run...why is that?
x = a;
while(x<b)
{
y = f(x);
printf("%lf %lf \n", x ,y );
x +=h;
}
system("Pause");
return(0);
}
Run Code Online (Sandbox Code Playgroud) 我将 Jetpack compose 用于 Android 应用程序。我想检索已在 Resources.Strings 中声明的字符串的字符串值。我尝试了一切,甚至上下文,但似乎没有任何效果。更具体地说,我想将 Resources 中的 String 值注册为可组合项修饰符的 contentDescription ,以便 TalkBack 可以将该值读取为用户的系统语言。即使在我使用用户方法时,调试器也会记录 int 值而不是 String .toString()。这是代码。
这是文件中的字符串values/strings.xml。
<string name="my_string">Something</string>
Run Code Online (Sandbox Code Playgroud)
这是可组合项的一些代码:
....modifier = Modifier
.fillMaxWidth()
.focusRequester(focusRequesters[1])
.clearAndSetSemantics { contentDescription = R.string.mystring.toString() }
)
val test= (R.string.my_string)
Log.d("Test",""+ test )
Run Code Online (Sandbox Code Playgroud)
调试器向 Android Studio 的 Logcat 显示一个整数值。这是 Logcat 的输出:
D/Test: 2131623845
Run Code Online (Sandbox Code Playgroud)
预期结果应该是:
D/Test: Something
Run Code Online (Sandbox Code Playgroud)