我想知道,是否有可能在c中的两个限制之间生成一个随机数.即我的程序设置如下:
function x
{
generate random number;
}
while(1)
{
function x;
delay
}
Run Code Online (Sandbox Code Playgroud)
所以我需要在每次调用函数时生成一个随机数,但数字必须介于100和800之间
我知道有一个已经制作的函数叫做random和randmize,stdlib.h
我只是不知道如何创建上限和下限
谢谢
是否可以在选项菜单上创建,但将其放在页面底部.我正在和我一起工作 <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />.我知道默认情况下它位于顶部,但我认为它可以被买到底部.我只是不知道如何.这是我的代码
option_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/scan"
android:icon="@android:drawable/ic_menu_search"
android:title="@string/connect"/>
<item android:id="@+id/discoverable"
android:icon="@android:drawable/ic_menu_mylocation"
android:title="@string/discoverable"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
main.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.option_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.scan:
// Launch the DeviceListActivity to see devices and do scan
Intent serverIntent = new Intent(this, DeviceListActivity.class);
startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
return true;
case R.id.discoverable:
// Ensure this device is discoverable by others
ensureDiscoverable();
return true;
}
return …Run Code Online (Sandbox Code Playgroud)