头像

日月星辰




离线:20小时前


最近来访(13)
用户头像
Aaron0808
用户头像
xjtu_zfw
用户头像
冰之韵
用户头像
zeng9999jian
用户头像
忘打周赛
用户头像
Acxxqq
用户头像
im0use
用户头像
安德维京
用户头像
JcWing
用户头像
kongla
用户头像
yxc

活动打卡代码 AcWing 720. 连续整数相加

#include <bits/stdc++.h>
using namespace std;
int a , n , i , s;
int main()
{
    cin >> a;
    while (cin >> n,n <= 0);
    for (i = 0;i < n;i++)
    {
        s = s + a + i;
    }
    cout << s << endl;
    return 0;
} 



#include <bits/stdc++.h>
using namespace std;
int a , n , i , s;
int main()
{
    cin >> a;
    while (cin >> n,n <= 0);
    for (i = 0;i < n;i++)
    {
        s = s + a + i;
    }
    cout << s << endl;
    return 0;
} 



#include <bits/stdc++.h>
using namespace std;
int i , n , x , y;
int main()
{
    cin >> x >> y;
    if (x > y)
    {
        swap(x , y);
    }
    i = x + 1;
    while (i < y)
    {
        if (i % 2)
        {
            n += i;
        }
        i++;
    }
    cout << n << endl;
} 



#include <bits/stdc++.h>
using namespace std;
int i , n , x , y;
int main()
{
    cin >> x >> y;
    if (x > y)
    {
        swap(x , y);
    }
    i = x + 1;
    while (i < y)
    {
        if (i % 2)
        {
            n += i;
        }
        i++;
    }
    cout << n << endl;
} 



#include <bits/stdc++.h>
using namespace std;
int i , n;
int main()
{
    cin >> n;
    for (i = 1;i <= n;i++)
    {
        if (n % i == 0)
        {
            cout << i << endl;
        }
    }
} 


活动打卡代码 AcWing 724. 约数

#include <bits/stdc++.h>
using namespace std;
int i , n;
int main()
{
    cin >> n;
    for (i = 1;i <= n;i++)
    {
        if (n % i == 0)
        {
            cout << i << endl;
        }
    }
} 



#include <bits/stdc++.h>
using namespace std;
int i , n , cnt , m;
int main()
{
    cin >> n;
    while (n--)
    {
        cin >> i;
        if (10 <= i && i <= 20)
        {
            cnt++;
        }
        else
        {
            m++;
        }
    }
    cout << cnt << " in" << endl;
    cout << m << " out"  << endl;
} 


活动打卡代码 AcWing 713. 区间 2

···

include [HTML_REMOVED]

using namespace std;
int i , n , cnt , m;
int main()
{
cin >> n;
while (n–)
{
cin >> i;
if (10 <= i && i <= 20)
{
cnt;
}
else
{
m
;
}
}
cout << cnt << ” in” << endl;
cout << m << ” out” << endl;
}
```




不会循环用数组吧
#include <bits/stdc++.h>
#define MX 50
using namespace std;
int a[MX] = {0 , 1};
int i , n;
int main()
{
    cin >> n;
    if (n == 0)
    {
        cout << 0;
    }
    else
    {
        cout << a[0] << " ";
        cout << a[1] << " ";
    }
    for (i = 2;i < n;i++)
    {
        a[i] = a[i - 1] + a[i - 2];
        cout << a[i] << " ";
    }
    cout << endl;
} 


活动打卡代码 AcWing 717. 简单斐波那契

#include <bits/stdc++.h>
#define MX 50
using namespace std;
int a[MX] = {0 , 1};
int i , n;
int main()
{
    cin >> n;
    if (n == 1)
    {
        cout << 0;
    }
    else
    {
        cout << a[0] << " ";
        cout << a[1] << " ";
    }
    for (i = 2;i < n;i++)
    {
        a[i] = a[i - 1] + a[i - 2];
        cout << a[i] << " ";
    }
    cout << endl;
}