CSDN论坛 > .NET技术 > C#

下面是一个老兄写的俄罗斯方块的类,请教Source数组为什么要那样初始化?tempit[i,0]=temp[i*2]-'0';中的temp[i*2]-'0'又是什么意思? [问题点数:20分,结帖人rerli]

Bbs1
本版专家分:0
结帖率 100%
CSDN今日推荐
Bbs7
本版专家分:10544
Blank
红花 2003年2月 VB大版内专家分月排行榜第一
Bbs2
本版专家分:294
Bbs2
本版专家分:177
匿名用户不能发表回复!
其他相关推荐
插入排序算法 c实现
int main(){ const int n = 7; int numbers[n]; for( int i = 0; i < n; i++){ cin>>numbers[i]; } for( int i = 1; i < n; i ++){ int temp = numbers[i]; int j = i - 1; for( ; j >= 0; j--){ if( numbers[j] > temp ){ numbers[j+1] = numbers[j]; } else{ break; } } numbers[j+1] = temp; } for ( int i = 0; i < n; i ++){ cout<<numbers[i]<<" "; } return 0; }
作业3 算法时间复杂度和空间复杂度
1-1 2​N​​和N​N​​具有相同的增长速度。 (2分) T         F 1-2 N​2​​logN和NlogN​2​​具有相同的增长速度。 (2分) T         F 1-3 在任何情况下,时间复杂度为O(n​2​​) 的算法比时间复杂度为O(n*logn)的算法所花费的时间都长。 (1分) T  
C语言考试
1、程序char c[5]={‘a’,’b’,’’,’c’,’’}; printf(“%s”,c);的运行结果是: 答案:(D)  A、'a''b'  B、ab  C、ab c  D、ab 2、以下程序的输出结果是:#include main(){  int a=2,c=5;  printf("a=%%d,b=%%d ",a,c);} 答案:(D)  A、a=%2,b=%5
指定特殊字符不能使用
function validate(str){ var illegalChars = ['*','-'];//指定的特殊字符写在这个数组里面,个数不限。 str = str.value; var numberCount = 0; var upperCaseCount = 0; var lowerCaseCount = 0; var otherCharCount = 0; var numberIndex = 0; var upperCaseIndex = 0; var lowerCaseIndex = 0; var otherCharIndex = 0; var temp; for (var i = 0; i < str.length; i++) { temp = str.charAt(i); for(var j = 0; j < illegalChars.length; j++){ if(temp == illegalChars[j]){ return false; } } temp = temp.charCodeAt(); if (temp >= 48 && temp <= 57) { numberIndex = i; numberCount++; }else if(temp >= 65 && temp <= 90){ upperCaseIndex = i; upperCaseCount++; }else if(temp >= 97 && temp <= 122){ lowerCaseIndex = i; lowerCaseCount++; }else{ otherCharIndex = i; otherCharCount++; } } if (numberCount == 0 || (numberCount == 1 && (numberIndex == 0 || numberIndex == str.length-1 ))) { return false; } if (upperCaseCount == 0 || (upperCaseCount == 1 && (upperCaseIndex == 0 || upperCaseIndex == str.length-1 ))) { return false; } if (lowerCaseCount == 0 || (lowerCaseCount == 1 && (lowerCaseIndex == 0 || lowerCaseIndex == str.length-1 ))) { return false; } if (otherCharCount == 0 || (otherCharCount == 1 && (otherCharIndex == 0 || otherCharIndex == str.length-1 ))) { return false; } return true; }
2010.10.22密码校验(小写,大写,数字)
private boolean checkPassword(String password) { int numberCount = 0; int upperCaseCount = 0; int lowerCaseCount = 0; int numberIndex = 0; int upperCaseIndex = 0; int lowerCaseIndex = 0; for (int i = 0; i < password.length(); i++) { char temp = password.charAt(i); if (temp >= 48 && temp <= 57) { numberIndex = i; numberCount++; }else if(temp >= 65 && temp <= 90){ upperCaseIndex = i; upperCaseCount++; }else if(temp >= 97 && temp <= 122){ lowerCaseIndex = i; lowerCaseCount++; } } if (numberCount == 0 || (numberCount == 1 && (numberIndex == 0 || numberIndex == password.length()-1 ))) { return false; } if (upperCaseCount == 0 || (upperCaseCount == 1 && (upperCaseIndex == 0 || upperCaseIndex == password.length()-1 ))) { return false; } if (lowerCaseCount == 0 || (lowerCaseCount == 1 && (lowerCaseIndex == 0 || lowerCaseIndex == password.length()-1 ))) { return false; } return true; }
华为笔试题
华为各个职位笔试题 #include <stdio.h> #include <iostream.h> #include <ctype.h> #include <string.h> void fun(char a[]) { int i,j,m=0,s=0,strl; strl=strlen(a); char temp[30]={0}; for(i=strl-1;i>=0;i--) {if(!isspace(a[i])) m++; else { for(j=1;j<=m;j++) temp[s++]=a[i+j]; m=0; } if(isspace(a[i])) temp[s++]=a[i]; } for(j=1;j<=m;j++) temp[s++]=' '; temp[s]='\0'; strcpy(a,temp);
回溯递归解决背包问题
回溯递归解决背包问题 int temp_c,i,total_weight,num,j=0,result[1000],total_value; scanf("%d%d",&num;,&temp;_c); while(num!=0||temp_c!=0) { total_value=0; total_weight=0; for(i=0;i<=10;++i) { a[i]=0; b[i]=0; w[i]=0; } c=temp_c; n=num; for(i=0;i<num;++i) { scanf("%d",&w[i]); total_weight+=w[i]; } for(i=0;i<num;++i) { scanf("%d",&b[i]); total_value+=b[i]; } if(total_weight<=c) result[j]=total_value; else { best_value=0; Sesearch(0,total_value-b[0],0,0); result[j]=best_value; } scanf("%d%d",&num;,&temp;_c); ++j; } for(i=0;i<j;++i) printf("%d\n",result[i]); }
python写俄罗斯方块
#coding=utf-8 from tkinter import * from random import * import threading from tkinter.messagebox import showinfo from tkinter.messagebox import askquestion import threading from time import sleep ...
C冒泡排序发
c实现冒泡排序比较简单的一个程序 #include<stdio.h> int main() { int table[10]={1,34,435,65,65,65,56,656,3,4}; int i,j; int temp; int lenth=sizeof(table)/sizeof(table[0]); for(i=0;i<lenth;i++) { if(table[i]<table[i+1]){ table[i]=temp; table[i]=table[i+1]; table[i+1]=temp; } } for(j=0;j<lenth;j++) { printf("%d",table[j]); } system("pause"); return 0; }
大整数的乘法----
while(k<=2*l) { temp=0; s[k]=0; for(i=0;i<=l;i++) { for(j=0;j<=l;j++) { if((i+j)==k-1) { temp+=(m[l-i]-48)*(n[l-j]-48); } } } v=(temp+t)%10; s[k]=v; t=(temp+t)/10; k++; } temp=0; for(i=0;i<=l;i++) { for(j=0;j<=l;j++) if((i+j)==k-1) { temp+=(m[l-i]-48)*(n[l-j]-48); } } temp+=t;
关闭