比较简单,只要搞懂b2ten()函数的算法即可源码#include #include long b2ten(char* x, int b) { int ret = 0; int len = strlen(x); for (int i = 0; i = b) return -1; ...
分类:
其他好文 时间:
2015-04-23 17:12:09
阅读次数:
127
// 有一函数:x 0,y = 1,编程输入一个x值,要求输出对应的y
#include
int main()
{
int x,y;
printf("请输入x:");
scanf("%d",&x);
if(x > 0)
y = 1;
else if(x < 0)
y = -1;
else
y = 0;
printf("对应的y值是:%d\n",y);
ret...
分类:
编程语言 时间:
2015-04-23 13:17:08
阅读次数:
398
#include
char *my_strcpy(char *dest,const char *src)
{
char *ret = dest;//保存数组的首地址,下面的操作会改变dest的值
while((*dest = *src) != '\0')//将src数组的内容全部赋给dest,包括'\0',当'\0'拷贝过去之后拷贝完成即函数结束
{
src++;
dest++;...
分类:
其他好文 时间:
2015-04-22 00:41:14
阅读次数:
205
#include
#include
using namespace std;
class Triangle
{
public:
void setA(double x)
{
a = x;
}
void setB(double y)
{
b = y;
}
void setC(double z)
{
c = z;
}
double getA()
{
ret...
分类:
其他好文 时间:
2015-04-21 22:42:57
阅读次数:
155
考察优先队列,以及对队列的一系列操作
#include
#include
#define maxn 10000+10
using namespace std;
struct stu
{
string name;
int rp;
friend bool operator<(stu x,stu y)
{
if(x.rp==y.rp) return x.name<y.name;
ret...
分类:
其他好文 时间:
2015-04-21 16:09:20
阅读次数:
154
有两个变量a,b,不用if ?: switch或其他判断语句找出两个中比较大的int max = ((a + b) + abs(a-b)) / 2给三个整数a,b,c函数实现取三个数的中间数,不可以使用sort,整数操作尽可能少1 inline int max(int a, int b) ( ret...
分类:
其他好文 时间:
2015-04-19 17:29:40
阅读次数:
108
表达式定义:[ capture-list ] ( params ) mutable(optional) exception attribute -> ret { body } (1)
[ capture-list ] ( params ) -> ret { body } (2)
[ capture-list ] ( params ) { body } (3)...
分类:
其他好文 时间:
2015-04-17 18:14:13
阅读次数:
157
标题:Rotate List通过率:21.8%难度:中等Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,ret...
分类:
其他好文 时间:
2015-04-17 13:01:12
阅读次数:
94
1.两个链表都带有头结点Node* Merge(Node* head1, Node* head2){ if(head1==NULL || head1->next==NULL) return head2; if(head2==NULL || head2->next==NULL) ret...
分类:
其他好文 时间:
2015-04-16 06:44:16
阅读次数:
110
今天在写一个给第三方同步数据的接口时遇到一个这种情况,我有一大坨数据,但是第三方只需要其中的几个而已,不及思索的就开始foreach$ret = array();foreach ($needParams as $pk) { if (isset($params[$pk])) { $...
分类:
编程语言 时间:
2015-04-16 01:14:00
阅读次数:
160