我正在研究一项游戏,其中分数被提交到活动中的排行榜,并且新的高分显示在片段中的排名.我有一些(有点)功能,但成功率约为10%.
流程如下:
方法handleLeaders
此方法获取每个排行榜的当前分数,如果新分数更好,则提交它并使用分数创建新的newHigh对象并将其添加到ArrayList.处理完所有3个排行榜后,调用方法setHighs.(在每个排行榜调用中检查错误)
public void handleLeaders(boolean win, int size, double t, final int toupees) {
if(win) {
final long time = (long) t;
// Toupees
Games.Leaderboards.loadCurrentPlayerLeaderboardScore(mGoogleApiClient,
getString(R.string.leaderboard_trumps_toupeed),
LeaderboardVariant.TIME_SPAN_ALL_TIME,
LeaderboardVariant.COLLECTION_PUBLIC).setResultCallback(
new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {
@Override
public void onResult(Leaderboards.LoadPlayerScoreResult arg0) {
LeaderboardScore c = arg0.getScore();
int old;
if (c != null)
old = (int) c.getRawScore();
else
old = 0;
Games.Leaderboards.submitScore(mGoogleApiClient, getResources().getString(R.string.leaderboard_trumps_toupeed), old + toupees);
GameEndOverlay.newHighs.add(new newHigh("Trumps Toupee'd", old + toupees));
Status status = arg0.getStatus();
int statusCode = status.getStatusCode();
if (statusCode == GamesStatusCodes.STATUS_NETWORK_ERROR_NO_DATA) …
Run Code Online (Sandbox Code Playgroud) 我正在使用Nutiteq SDK,它包含一个MapView,我也试图使用导航抽屉.我遇到的问题是,无论何时我从左侧滑动或单击图标打开抽屉都没有打开,但我无法移动地图,直到我向后滑动抽屉或再次单击图标.这让我相信抽屉是打开但没有显示.这是我的MainActivity.java和activity_main.xml:
MainActivity.java
public class MainActivity extends Activity {
private MapView mapView;
private LocationListener locationListener;
private GeometryLayer locationLayer;
private Timer locationTimer;
private String[] drawerListViewItems;
private ListView drawerListView;
private DrawerLayout drawerLayout;
private ActionBarDrawerToggle actionBarDrawerToggle;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setMap();
// get list items from strings.xml
drawerListViewItems = getResources().getStringArray(R.array.items);
// get ListView defined in activity_main.xml
drawerListView = (ListView) findViewById(R.id.left_drawer);
// Set the adapter for the list view
drawerListView.setAdapter(new ArrayAdapter<String>(this,
R.layout.drawer_listview_item, drawerListViewItems));
// App Icon
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); …
Run Code Online (Sandbox Code Playgroud) 所以,我要做的是创建一个将大写字符切换为小写的函数,反之亦然.
这是我正在使用的:
#include <stdio.h>
#include <stdlib.h>
int caplowswitch(char string[], char switched[]);
int main(){
char name[] = "whyisthisnotworking";
char flipped[] = "";
caplowswitch(name, flipped);
return 0;
}
int caplowswitch(char word[], char switched[]){
char *ptrword = word;
unsigned short int counter = 0;
printf("Your text input is: %s \n", word);
while(*ptrword != NULL){
switched[counter] = (*ptrword ^ 0x20);
counter++;
ptrword++;
}
printf("Your flipped text is: %s \n", switched);
return 1;
}
Run Code Online (Sandbox Code Playgroud)
在学习的过程中.谢谢你的时间.
char player_select(void){
char player = 'n';
while(player == 'n'){
printf("Select your player (X or O): ");
scanf("%c\n", &player);
if(player != 'X' && player != 'O'){
printf("Invalid input. Try again.\n");
player = 'n';
}
}
printf("Your character input is: %c\n", player);
exit(0);
return player;
}
Run Code Online (Sandbox Code Playgroud)
我在这里得到一些奇怪的输出:
选择你的播放器(X或O):X
输入无效.再试一次.
选择你的播放器(X或O):i
你的角色输入是:X
我的脚本打开两个文件:whitelist.txt和blacklist.txt填充ip地址.
我想在whitelist.txt中将blacklist.txt中所有ip的实例添加到变量中.
此脚本最多可以存储2个通配符.
它现在运行37分钟,我希望这更快.
$blacklist = file_get_contents("blacklist.txt");
$whitelist = file_get_contents("whitelist.txt");
$black_ips = explode("\n", $blacklist);
$white_ips = explode("\n", $whitelist);
$wildcard = array();
for($i = 0; $i < 256; $i++) {
$wildcard[] = $i;
}
foreach($black_ips as $bkey => $black) {
if(stristr($black, ".")) {
foreach ($white_ips as $wkey => $white) {
$count = substr_count($white, '*');
if($count) {
switch($count){
case 1:
foreach ($wildcard as $i) {
if(substr($white, 0, strlen($white) - 1) . $i == $black){
continue 4;
}
}
break;
case 2:
foreach …
Run Code Online (Sandbox Code Playgroud)