其他分享
首页 > 其他分享> > Dailycode_7.10(剪花布条、客似云来)

Dailycode_7.10(剪花布条、客似云来)

作者:互联网

在这里插入图片描述

// write your code here cpp
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main()
{
	string s, t;
	while (cin >> s >> t)
	{
		if (t.size() > s.size())
		{
			cout << 0 << endl;
			break;
		}
		int sz = t.size();
		int i = 0;
		int count = 0;
		while ((i + sz - 1) < s.size())
		{
			string ret;
			for (int j = i; j < sz + i; j++)
			{
				ret.push_back(s[j]);
			}
			if (strcmp(ret.c_str(),t.c_str()) == 0)
			{
				i = i + sz;
				count++;
			}
			else
			{
				i++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

在这里插入图片描述

// write your code here cpp
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int a,b;
    while (cin >> a >> b)
    {
        vector<long> arr;
        arr.resize(b + 1);
        arr[0] = 0;
        arr[1] = 1;
        arr[2] = 1;
        long count = 0;
        for (int i = 2; i <= b; i++)
            arr[i] = arr[i - 1] + arr[i - 2];
        for (int i = a;i <= b; i++)
        {
            count += arr[i];
        }
        cout << count << endl;
    }
    return 0;
}

标签:arr,code,7.10,int,剪花,Dailycode,include,your,size
来源: https://blog.csdn.net/lxy_zzZ/article/details/95343596