void dfs(string &s, int pos, vector<string> &path, vector<string> &res)
 {
     if(pos == s.size())
     {
         if(path.size() == 4)
         {
             res.push_back(path[0] + "." + path[1] + "." + path[2] + "." +  path[3]);
         }
     }
     else
     {
         int len = (int)s.size()-pos;
         for(int i=1; i<=min(3,len); i++)
         {
             if(i > 1 && s[pos] == '0') continue;
             int v = atoi1(s.substr(pos, i));
             if(v <= 255 && v >= 0 && path.size() < 4)
             {
                 path.push_back(s.substr(pos, i));
                 dfs(s, pos+i, path, res);
                 path.pop_back();
             }
         }
     }
 }
Exemple #2
0
int main()
{
int i=0;
char *s1[40];
printf("enter a string with +ve or -ve nos\n");
gets(s1);
i=atoi1(s1);
printf("i :%d\n",i);
return 0;
}
Exemple #3
0
int32_t ckph(void)
{
	Tchar i;
	int32_t j;

	if (cbits(i = getch()) == '(')
		j = atoi0();
	else {
		j = atoi1(i);
	}
	return(j);
}
int main()
{
	char s[8],a[20];
	int n,m;
	long k;
	while(scanf("%s%d%d",s,&n,&m)!=EOF)
	{
		k=atoi1(s,n);
		itoa(k,a,m);
		if(strlen(a)>7)printf("  ERROR\n");
		else
		{
			for(n=0;a[n];n++)
			{
				if(a[n]>='a'&&a[n]<='z')
					a[n]='A'+a[n]-'a';
			}
			printf("%7s\n",a);
		}
	}
	return 0;
}
Exemple #5
0
void atom(int *value)
{
    int i;
    switch(token_type) {
    case IDENTIFIER:
        i = internal_func(token);
        if(i!= -1)     
            *value = (*intern_func[i].p)();
        else if(find_func(token)) { 
            call();
            *value = ret_value;
        }
        else
            *value = find_var(token); 
        get_token();
        return;
    case NUMBER: 
        *value = atoi1(token);
        get_token();
        return; 
    case DELIMITER: 
        if(*token=='\'') {
            *value = *prog;
            prog++;
            if(*prog!='\'') 
                sntx_err(QUOTE_EXPECTED);
            prog++;
            get_token();
        }
        return;
    default:
        if(*token==')') 
            return;
        else
            sntx_err(SYNTAX); 
    }
}