我试图排序(减少)一个整数数组,但跟踪原始索引.
我的意思是,例如,如果我有这个数组:
b[] = { 4, 5, 3, 5, 2 }
Run Code Online (Sandbox Code Playgroud)
在使用Arrays.sort(b,Collections.reverseOrder())后,它变成了(我使用的是Arrays.sort,因为在这个例子中b只有长度为5,但在我的问题中,b的长度可以是1 <b.length <70
b[] = { 5, 5, 4, 3, 2 }
Run Code Online (Sandbox Code Playgroud)
但我想以某种方式拥有原始索引,我的意思是知道这一点
bOrignalIndex[] = { 1, 3, 0, 2, 4 }
Run Code Online (Sandbox Code Playgroud)
我不知道我的问题是否清楚,请问我一切.我在C++中有这段代码可以提供帮助,因为它可以满足我的需要
n=4
m=5
tord[] =
[0] 0
[1] 1
[2] 2
[3] 3
ts[] =
[0] 4
[1] 5
[2] 3
[3] 5
tord[MAXT], ts[MAXT];
bool ord(int a, int b){
return ts[a] > ts[b]; }
int main(void){
for(int m, n; scanf("%d %d", &m, &n)){
bool possible = …Run Code Online (Sandbox Code Playgroud) 我已经设法将GCM与Android设备一起使用,但现在我正在尝试在iOS应用上实现.
我想我已经遵循了所有必要的步骤来使用GCM服务.我已按照https://developers.google.com/cloud-messaging/ios/client?configured=true将服务添加到现有应用中.
我认为一切都配置正确,但我无法收到任何通知.我有APN证书和GoogleService-info.plist文件,在控制台上这是输出:
2016-01-05 13:47:53.864:GCM | 签入plist中的密钥无效:GMSInstanceIDDeviceDataVersion连接到GCM 2016-01-05 13:47:57.501:GGLInstanceID | 将来的签到时间戳无效.2016年1月5日13:47:57.501 TerneraGallega [1014:444977]与AUTHID签到成功:4958686017822257121,消化:KSJNg + Aj82uavBXrFeOAfA ==,lastCheckinTimestamp:1451998077000注册令牌:NC-dd9fCvFs:APA91bHMfbvLczxSPLQsLeEJASU_RfV4wvVuPs2u4VJDtpC8oB2cm1AKr6cH_LFeLsQzb94Kk9iwez8fsOvgzNns_9DU3i8Ema1oCKIwcNFzenNpAhViyGHah4E7-RkQlg1durYSEQRD已订阅/主题/全球
如果我发出POST请求,我会收到此消息:
{ "到": "NC-dd9fCvFs:APA91bHMfbvLczxSPLQsLeEJASU_RfV4wvVuPs2u4VJDtpC8oB2cm1AKr6cH_LFeLsQzb94Kk9iwez8fsOvgzNns_9DU3i8Ema1oCKIwcNFzenNpAhViyGHah4E7-RkQlg1durYSEQRD", "content_available":真实的, "通知":{ "体": "伟大的比赛!", "称号": "葡萄牙对丹麦"}}
第一次尝试它返回成功消息,但设备中没有显示日志和通知(应用程序位于前台)
几分钟后,再次尝试POST请求,它将返回失败
{"multicast_id":7256343774952522277,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]}
现在,我从Google页面下载了GCM示例,配置了APN并获得了GoogleService-info.plist,当它在设备上打开时启动GCM示例Swift文件它说:
注册成功!检查xcode调试控制台,你可以使用注册令牌...
在此之后,如果您设置POST请求
{ "到": "mVEtHyTXEOg:APA91bGvK_Uf2ZKgpguWUOto3CXQzIT1z22uJ446mYkNqMwL9VLDYdGtdm_4vS8rcl3T9OeqEC1UWbdKAOyuoweW1GiU0mv0cDSPW03y4XGx19JcR6rxsiWRNUjtADX6iNAW8wM8UBJl", "content_available":真实的, "通知":{ "体": "伟大的比赛!", "称号": "葡萄牙对丹麦"}}
它再次返回一个
{"multicast_id":7435981433811133310,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]}
在应用程序上实现GCM的人可以指出我缺少的东西吗?
- - - -编辑 - - - -
最后,我通过使用分发证书而不是开发证书使其工作......似乎我已经配置好了但是我遗漏了开发证书.
PS:在ID下的APN配置文件页面中,我启用了两个推送通知证书(这就是为什么我认为所有配置都很好)
但是我会把这个问题保持开放,因为我无法在开发环境下使用它
我正面临这种特殊行为,我不知道如何解决它..
在我的活动中,我有这个工具栏:
当您单击搜索图标时,它会展开并将另一个图标推出视图.
我想知道如何将图标保持在右侧并减少搜索视图空间.
这是我的菜单布局:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_search"
android:title="@string/buscar"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always" />
<item
android:id="@+id/alimentos_basket"
android:orderInCategory="1"
android:title="@string/alimentos_anadidos"
app:showAsAction="always" />
Run Code Online (Sandbox Code Playgroud)
在我的活动布局中,我什么都没有
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.irixgalicia.irixhealth.app.comidaDiaria.AnadirAlimentoActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_anadir_alimento" />
Run Code Online (Sandbox Code Playgroud)
这些是我膨胀的活动的代码
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_anadir_alimento, menu);
final MenuItem menuItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
searchView.setOnQueryTextListener(this);
final MenuItem contadorItem = menu.findItem(R.id.alimentos_basket);
contadorItem.setIcon(buildCounterDrawable(contadorAlimentos, R.drawable.ic_food_variant_white_36dp));
return super.onCreateOptionsMenu(menu);
}
Run Code Online (Sandbox Code Playgroud)
在我的布局中,我只有工具栏,而不是里面的图标.
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"> …Run Code Online (Sandbox Code Playgroud) 我正在使用C++ http://ajmarin.alwaysdata.net/codes/problems/952/阅读此代码,
我不明白&=代码中的内容:
int k = 5;
int ts = 5;
bool possible = true;
Run Code Online (Sandbox Code Playgroud)
它有这条线:
if(!(possible &= k == ts))
break;
Run Code Online (Sandbox Code Playgroud)
我想知道"&="我是C++语言的新手是什么意思,我从来没有见过像java这样的东西,或者至少我不知道它的含义.
"1"由于(k == ts)是(5 == 5)但左手(possible &= k)不知道含义,因此语句的右手返回.
谢谢
我正在学习Java,我正在将一些C++代码编写到java中,我正在关注这个网页http://uva.onlinejudge.org并尝试用Java来解决一些问题.现在我正在做这个问题http://uva.onlinejudge.org/index.phpoption=com_onlinejudge&Itemid=8&page=show_problem&problem=1072,经过研究并弄清楚如何在纸上做到这一点我找到了这个网页,问题似乎很容易遵循:http: //tausiq.wordpress.com/2010/04/26/uva-10131/
但是现在,由于我是Java的新手,我想学习如何在Java中使用struct数组.我现在可以做类似结构的类:如果这是在C++中
struct elephant {
int weight;
int iq;
int index;
} a [1000 + 10];
Run Code Online (Sandbox Code Playgroud)
我可以用Java做到这一点:
public class Elephant {
private int _weight;
private int _iq;
private int _index;
public Elephant(int weight, int iq, int index) {
this._weight = weight;
this._iq = iq;
this._index = index;
}
public int getWeight() {
return this._weight;
}
public int getIQ() {
return this._iq;
}
public int getIndex() {
return this._index;
}
public void setWeigth(int w) …Run Code Online (Sandbox Code Playgroud) 我正在我的应用程序上实现材料设计,我希望能够将抽屉图标的颜色更改为白色,但我无法实现我正在寻找的东西..
这是我的themes.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="AppTheme.Base" />
<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
<style name="HeaderBar" parent="AppTheme.Base">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:background">@color/primary</item>
<item name="actionMenuTextColor">@android:color/white</item>
<item name="android:textColorSecondary">@android:color/white</item>
<item name="android:actionMenuTextColor">@android:color/white</item>
</style>
<style name="ActionBarPopupThemeOverlay" parent="ThemeOverlay.AppCompat.Light">
<item name="android:background">@android:color/white</item>
<item name="android:textColor">#000</item>
</style>
<style name="ActionBarThemeOverlay" parent="">
<item name="android:textColorPrimary">#fff</item>
<item name="colorControlNormal">#fff</item>
<item name="colorControlHighlight">#3fff</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
这是我的toolbar.xml文件
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/jpe.serviguide.commobile"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ActionBarPopupThemeOverlay"
app:theme="@style/HeaderBar" />
Run Code Online (Sandbox Code Playgroud)
我想要的所有颜色都很好,但抽屉图标是黑色而不是白色..

我已经尝试了很多东西,但没有欲望的结果
非常感谢
android ×2
c++ ×2
java ×2
android-menu ×1
arrays ×1
comparator ×1
if-statement ×1
ios ×1
layout ×1
sorting ×1
struct ×1
swift ×1