예제 #1
0
PRIVATE void expand_dim(struct comal_line *line)
{
	struct dim_list *root = NULL;
	struct dim_list *work;
	struct dim_ension *droot;
	struct dim_ension *dwork;

	while (expand_peekc() == SQ_ID) {
		work =
		    mem_alloc_private(curenv->program_pool,
				      sizeof(struct dim_list));
		work->next = root;
		root = work;

		work->id = expand_getid();
		droot = NULL;

		while (expand_peekc() == SQ_1DIMENSION) {
			expand_getc();
			dwork =
			    mem_alloc_private(curenv->program_pool,
					      sizeof(struct dim_ension));
			dwork->next = droot;
			droot = dwork;
			dwork->bottom = expand_exp();
			dwork->top = expand_exp();
		}

		work->dimensionroot = my_reverse(droot);
		work->strlen = expand_exp();
	}

	line->lc.dimroot = my_reverse(work);
}
예제 #2
0
int		my_init2(int *pile1, int *pile2, int *s, int r[3][5])
{
	r[1][0] = my_swap(pile1, s[1], 1);
	r[1][1] = my_rotate(pile1, s[1], 1);
	r[1][2] = my_reverse(pile1, s[1], 1);
	r[2][0] = my_swap(pile2, s[2], -1);
	r[2][1] = my_rotate(pile2, s[2], -1);
	r[2][2] = my_reverse(pile2, s[2], -1);
	return (1);
}
 void reverseWords(s)
 {   int pos = start = 0;
     handle(s);
     my_reverse(s, 0, s.length() - 1); //将整个字符串逆序
     for(pos; pos <= s.length(); pos++)
     {
         if(s[pos] == ' ' || pos == s.length())
          {
              my_reverse(s, start, pos - 1);
              start = pos + 1;
          }
     }
 }
bool my_next_permutation(int *a,int n,int size){
	if(n<0||size<n)return false;
	int i;
	my_reverse(a,n,size-n);
	for(i=size-2;i>=0;i--)if(a[i]<a[i+1])break;
	if(i<0){
		my_reverse(a,0,size);
		return false;
	}
	int k=i;
	for(i=size-1;i>=k+1;i--)if(a[k]<a[i])break;
	int l=i;
	int z=a[k];a[k]=a[l];a[l]=z;
	my_reverse(a,k+1,size-(k+1));
	return true;
}
예제 #5
0
파일: exe4.c 프로젝트: Geovo/iCu
void myitoa(char *s, int n) {
    int power = 1;
    char *c = s; // just to be able to revert the whole string afterwards
    while (n > 0) {
        *s = n % 10 + '0';
        n /= 10;
        s++;
    }
    *++s = '\0';
    my_reverse(c); // now reverse the whole string
}
예제 #6
0
PUBLIC struct expression *pars_exp_id(int op, struct id_rec *id,
				      struct exp_list *exproot)
{
	GETEXP(sizeof(struct exp_id));

	work->optype = T_ID;
	work->op = op;
	work->e.expid.id = id;
	work->e.expid.exproot = my_reverse(exproot);

	return work;
}
int main() 
{
    int len;
    char line[MAXLINE];

    while ((len = my_getline(line, MAXLINE)) > 0) {
        printf("origin: %s", line);
        my_reverse(line);
        printf("%s", line);
    }
    return 0;
}
예제 #8
0
void test(int size) {
	std::vector<int> v(size);

	std::cout << "size: " << size << std::endl;
	
	std::generate(v.begin(), v.end(), randNum);
	std::copy(v.begin(), v.end(), std::ostream_iterator<int>(std::cout, " "));
	std::cout << std::endl;
	my_reverse(v.begin(), v.end());
	std::copy(v.begin(), v.end(), std::ostream_iterator<int>(std::cout, " "));
	std::cout << std::endl;
	
}
예제 #9
0
PUBLIC struct dim_list *pars_dimlist_item(struct id_rec *id,
					  struct expression *strlen,
					  struct dim_ension *root)
{
	struct dim_list *work =
	    mem_alloc(PARSE_POOL, sizeof(struct dim_list));

	work->id = id;
	work->strlen = strlen;
	work->dimensionroot = my_reverse(root);

	return work;
}
예제 #10
0
int main()
{
	int numbers[]={10,20,30,40,50};
	MyIterator from(numbers);
	MyIterator until(numbers+5);
	for (MyIterator it=from; it!=until; it++)
		std::cout << *it << ' ';
	std::cout << '\n';

	// F*****g the Question 5 in http://blog.csdn.net/fengbingyang/article/details/8764931
	// refer to http://programmers.stackexchange.com/questions/153386/why-is-x-x-undefined
	int x=10;
	x = x++;
	from = from++;
	printf("int++: %d, iter++: %d\n",x,*from);

	std::vector<int> vc1(numbers, numbers+5);
	std::vector<int> vc2(vc1.begin(), vc1.end());

	std::vector<int> v(vc1);
	auto mid1 = my_reverse(v.begin(), v.end());
	for (int n : v)
		std::cout << n << ' ';
	std::cout << "Mid: " << mid1 <<'\n';

	std::list<int> l(numbers, numbers+5);
	auto mid2 = my_reverse(l.begin(), l.end());
	for (auto n : l)
		std::cout << n << ' ';
	std::cout << "Mid: " << mid2<< '\n';

	//    std::istreambuf_iterator<char> i1(std::cin), i2;
	//    my_reverse(i1, i2); // compilation error

	return 0;
}
예제 #11
0
파일: useful.c 프로젝트: Zyrter/super-osd
/**
 * my_itoa: convert n to characters in s. This version is slightly
 * modified; it returns the number of bytes (including NUL) written.
 *
 * @param	number (long int)
 * @param	string buffer
 *
 * @return 	Bytes written
 */
int my_itoa(long int n, char s[])
{
	long int i, sign;
	if ((sign = n) < 0)	            /* record sign */
		n = -n;				        /* make n positive */
	i = 0;
	do                              /* generate digits in reverse order */
	{	   
		s[i++] = n % 10 + '0';      /* get next digit */
	} while ((n /= 10) > 0);	    /* delete it */
	if (sign < 0)
		s[i++] = '-';
	s[i] = '\0';
	my_reverse(s);
	return i + 1;
}
예제 #12
0
PRIVATE struct print_list *expand_printlist()
{
	struct print_list *root = NULL;
	struct print_list *work;

	while (expand_peekc() == SQ_EXP) {
		work =
		    mem_alloc_private(curenv->program_pool,
				      sizeof(struct print_list));
		work->next = root;
		root = work;
		work->exp = expand_exp();
		work->pr_sep = expand_getint();
	}

	return my_reverse(root);
}
예제 #13
0
PRIVATE struct import_list *expand_importlist()
{
	struct import_list *root = NULL;
	struct import_list *work;

	while (expand_peekc() == SQ_1PARM) {
		expand_getc();
		work =
		    mem_alloc_private(curenv->program_pool,
				      sizeof(struct import_list));
		work->next = root;
		root = work;

		work->id = expand_getid();
		work->array = expand_getint();
	}

	return my_reverse(root);
}
예제 #14
0
PRIVATE struct exp_list *expand_explist()
{
	struct exp_list *root = NULL;
	struct exp_list *work;

	expand_check(SQ_EXPLIST);

	while (expand_peekc() != SQ_ENDEXPLIST) {
		work =
		    mem_alloc_private(curenv->program_pool,
				      sizeof(struct exp_list));
		work->exp = expand_exp();
		work->next = root;
		root = work;
	}

	expand_getc();

	return my_reverse(root);
}
예제 #15
0
PUBLIC struct expression *pars_exp_sid(struct id_rec *id,
				       struct exp_list *exproot,
				       struct two_exp *twoexp)
{
	GETEXP(sizeof(struct exp_sid));

	work->optype = T_SID;
	work->op = stringidSYM;
	work->e.expsid.id = id;
	work->e.expsid.exproot = my_reverse(exproot);

	if (!twoexp)
		work->e.expsid.twoexp = NULL;
	else {
		work->e.expsid.twoexp =
		    mem_alloc(PARSE_POOL, sizeof(struct two_exp));
		*work->e.expsid.twoexp = *twoexp;
	}

	return work;
}
예제 #16
0
PRIVATE struct assign_list *expand_assign()
{
	struct assign_list *work;
	struct assign_list *root = NULL;

	while (expand_peekc() == SQ_EXP) {
		work =
		    mem_alloc_private(curenv->program_pool,
				      sizeof(struct assign_list));
		work->next = root;
		root = work;

		work->lval = expand_exp();
		work->op = expand_getint();
		work->exp = expand_exp();

		if (comal_debug)
			my_printf(MSG_DEBUG, 1, "1Assign expanded");
	}

	return my_reverse(root);
}
예제 #17
0
파일: exe4.c 프로젝트: Geovo/iCu
int main(int argc, char *argv[])
{
    // awesome code goes here:
    char *s = "hello there!";
    char x[20];
    mystrcpy(x, s);
    my_reverse(x);

    printf("%s\n---------------------\n", x);
    char z[] = "184";
    printf("%i\n", myatoi(z));

    char a[10];
    myitoa(a, 192);
    printf("%s\n", a);

    char h[] = "Kristian";
    int res = myindex(h, "s");
    printf("s is at position %i in 'Kristian'\n", res);

    return 0;
}