头像

haohanxiang


访客:1561

离线:8个月前


活动打卡代码 AcWing 808. 最大公约数

haohanxiang
11个月前

include [HTML_REMOVED]

using namespace std;

int gcd(int a,int b)
{
for(int i = a; i; i –)
if(a % i == 0 && b % i == 0)

return i;

}
int main()
{
int a,b;
cin >> a >> b;

cout << gcd(a,b) << endl;
return 0;

}



活动打卡代码 AcWing 806. 两个数的和

haohanxiang
2019-05-26 01:47

include [HTML_REMOVED]

using namespace std;

double add(double x, double y)
{
return x + y;
}
int main()
{
double x, y;
cin >> x >> y;

printf("%.2lf", add(x, y));
return 0;

}



活动打卡代码 AcWing 805. x和y的最大值

haohanxiang
2019-05-26 01:34

include [HTML_REMOVED]

using namespace std;

int max(int x, int y)
{
if(x > y) return x;

return y;

}
int main()
{
int x, y;
cin >> x >> y;

cout << max(x, y);
return 0;

}



活动打卡代码 AcWing 804. n的阶乘

haohanxiang
2019-05-26 01:28

include [HTML_REMOVED]

using namespace std;

int fact(int a)
{
int r = 1;
while(a > 1)
r *= a –;
return r;
}
int main()
{
int x = fact(5);
cin >> x;
cout << fact(x);

return 0;

}




haohanxiang
2019-05-19 01:18

include [HTML_REMOVED]

include [HTML_REMOVED]

using namespace std;

int main()
{
char c[100];
int x = 0;
gets (c);

for (int i = 0; i < strlen(c); i ++)
    if (c[i] >= '0' && c[i] <= '9')
    x ++;
cout << x << endl;

return 0;

}



活动打卡代码 AcWing 760. 字符串长度

haohanxiang
2019-05-19 01:18

include [HTML_REMOVED]

include [HTML_REMOVED]

using namespace std;

int main()
{
char a[101];
gets (a);
cout << strlen(a) << endl;

return 0;

}



活动打卡代码 AcWing 741. 斐波那契数列

haohanxiang
2019-05-19 01:16

include [HTML_REMOVED]

using namespace std;

int main()
{
long long n;
long long a[61];
f[1] = 1, f[2]
for(int i = 2; i < 61) f[i] = f[i - 1] + f[i - 2]
printf(“Fib = %lld\n”, f[i]);

}



活动打卡代码 AcWing 741. 斐波那契数列

haohanxiang
2019-05-19 01:15

include [HTML_REMOVED]

using namespace std;

int main()
{
long long f[61];
f[0] = 1, f[1] = 1;

for(int i = 2; i < 61; i ++) f[i] = f[i - 1] + f[i - 2];

int t;
cin >> t;
while(t --)
{
int x;
cin >> x;
printf("Fib[%d] = %lld\n", x, f[x]);

}
return 0;
}



活动打卡代码 AcWing 740. 数组变换

haohanxiang
2019-05-19 01:14

include [HTML_REMOVED]

using namespace std;

int main()
{
int a[20];

for (int i = 0; i <= 19; i ++ )
{
    cin >> a[i];
    for (int x = a[i - 1]; x >= 0; x -- )
    printf ("N[%d] = %d\n", i , a[i]);
}
return 0;

}



活动打卡代码 AcWing 739. 数组选择

haohanxiang
2019-05-19 01:14

include [HTML_REMOVED]

include [HTML_REMOVED]

using namespace std;

int main()
{
float a[100];

for (int i = 0; i < 100; i ++ )  
{
    cin >> a[i];
    if (a[i] < 10) printf ("A[%d] = %.1f\n", i, a[i]);
}

return 0;

}