Example #1
0
unsigned long long int recurs(unsigned long long int n)
{
if(n<=1000000)
return a[n];
else
return (recurs(n/2)+recurs(n/3)+recurs(n/4));
}
Example #2
0
File: stat.c Project: Daykz/ft_ls
void				display_l_fold(char *param, t_opt *opt)
{
	t_list			*tmp;
	t_list			*list;
	t_list			*rmajfold;
	char			*str;
	int				i;

	i = 0;
	rmajfold = NULL;
	list = NULL;
	list = ft_ls(param, list, opt);
	check_total(param, list, opt);
	tmp = list;
	if (!list)
		return ;
	while (list)
	{
		str = make_path(str, param, list->data);
		if (fold_l(str, param, list, opt))
			list_add_next(&rmajfold, link_init(str));
		list = list->next;
	}
	print_l(tmp, opt);
	if (rmajfold)
		recurs(rmajfold, opt);
}
Example #3
0
QString DueDate::recurrenceString() const
{
    if (!recurs())
        return QString();

    switch (m_periodType) {
    case PeriodTypeNone:
        Q_ASSERT(false);
        return QString();
        break;
    case PeriodTypeDaily:
        return m_frequency == 1 ? QObject::tr("daily") : QObject::tr("every %1 days").arg(m_frequency);
        break;
    case PeriodTypeWeekly:
        return m_frequency == 1 ? QObject::tr("weekly") : QObject::tr("every %1 weeks").arg(m_frequency);
        break;
    case PeriodTypeMonthly:
        return m_frequency == 1 ? QObject::tr("monthly") : QObject::tr("every %1 months").arg(m_frequency);
        break;
    case PeriodTypeYearly:
        return m_frequency == 1 ? QObject::tr("yearly") : QObject::tr("every %1 years").arg(m_frequency);
        break;
    case PeriodTypeCount:
        Q_ASSERT(false);
        return QString();
        break;
    }

    return QString();
}
Example #4
0
 QStringList Recursive::recurs(const QString & path, bool subDir)  //рекурсія для знаходження файлів в папкавх
{
    QStringList list;
    QFileInfo info(path);
    QDir::Filters flag;
    if (subDir)
    {
        flag=QDir::AllEntries | QDir::NoDotAndDotDot;
    }
    else flag=QDir::Files;
    if (info.isDir()) //якщо директорія, передивляємося вміст
    {
        QDir dir_rec(path);

        QStringList list_rec(dir_rec.entryList(flag)); //передивляємося вміст
        if (list_rec.size()>0) //якщо список не пустий
            for (int i=0; i<list_rec.size();++i)
            {
                QString path1=dir_rec.canonicalPath()+"/"+list_rec[i];
                list.append(recurs(path1,subDir)); //розгортаємо все дерево файлів та папок
            }
    } else
    {
        if (info.suffix()=="img"||info.suffix()=="jpg"
                ||info.suffix()=="JPG"||info.suffix()=="bmp")
            list.append(path);
    }

    return list;
}
Example #5
0
int recurs(int a[], int size, int i) {
	if (i == 0) {
		return a[i];
	} else {
		return a[i] + recurs(a, size, i - 1);
	}
}
Example #6
0
int	recurs(char **format, va_list ap, int written)
{
	char *chr;

	if (**format == '%')
	{
		written += dispvar(format, ap);
		chr = *format;
		return (recurs(&chr, ap, written));
	}
	else if ((chr = ft_strchr(*format, '%')))
	{
		written += write(1, *format, chr - *format);
		return (recurs(&chr, ap, written));
	}
	else if ((chr = ft_strchr(*format, '\0')))
	{
		written += write(1, *format, chr - *format);
		return (written);
	}
	return (-1);
}
Example #7
0
int main() {
        int n, i;
        printf("rsum\nn: ");
        scanf("%d", &n);
        int a[n];
        for (i = 0; i < n; i ++) {
                printf("%d: ", i + 1);
                
		scanf("%d", &a[i]);
        }

	printf("sum:%d\n", recurs(a, n, n - 1));
        return 0;
}
Example #8
0
void Task::setStaged(bool staged)
{
    if (m_staged != staged) {
        m_staged = staged;
        emit stagedChanged();

        const QDate today = m_kernel->currentDate();
        if (!staged && recurs() && m_dueDate.date() <= today) {
            do {
                m_dueDate.makeNext();
            } while (m_dueDate.date() <= today);
            emit dueDateChanged();
        }
    }
}
Example #9
0
int main()
{
unsigned long long int i,j,t,k,n;
for(i=0;i<=11;i++)
a[i]=i;
for(i=12;i<=1000000;i++)
a[i]=a[i/2]+a[i/3]+a[i/4];
while(scanf("%llu",&n)!=EOF)
{
if(n<=1000000)
printf("%lld\n",a[n]);
else
{
unsigned long long int k=recurs(n);
printf("%lld\n",k);
}

}
return 0;
}
Example #10
0
QString DueDate::frequencyWord() const
{
    if (!recurs())
        return QString();

    switch (m_periodType) {
    case DueDate::PeriodTypeNone:
    case DueDate::PeriodTypeCount:
        Q_ASSERT(false);
        return QString();
    case DueDate::PeriodTypeDaily:
        return m_frequency == 1 ? QObject::tr("day") : QObject::tr("days");
    case DueDate::PeriodTypeWeekly:
        return m_frequency == 1 ? QObject::tr("week") : QObject::tr("weeks");
    case DueDate::PeriodTypeMonthly:
        return m_frequency == 1 ? QObject::tr("month") : QObject::tr("months");
    case DueDate::PeriodTypeYearly:
        return m_frequency == 1 ? QObject::tr("year") : QObject::tr("years");
    }

    return QString();
}
Example #11
0
void DueDate::makeNext()
{
    if (recurs())
        m_date = nextOcurrence();
}
Example #12
0
	if (**format == '%')
	{
		written += dispvar(format, ap);
		chr = *format;
		return (recurs(&chr, ap, written));
	}
	else if ((chr = ft_strchr(*format, '%')))
	{
		written += write(1, *format, chr - *format);
		return (recurs(&chr, ap, written));
	}
	else if ((chr = ft_strchr(*format, '\0')))
	{
		written += write(1, *format, chr - *format);
		return (written);
	}
	return (-1);
}

int	ft_printf(const char *restrict format, ...)
{
	int		ret;
	va_list	ap;

	va_start(ap, format);
	ret = recurs((char**)&format, ap, 0);
	va_end(ap);
	return (ret);
}