48(2023.12.15)c语言pta
2023-12-15 20:02:58
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
int n, k;
scanf("%d%d", &n, &k);
int arr[100] = { 0 };
for (int i = 0;i < n;i++)
{
arr[i] = i + 1;
}
int start = -1;
int fx = 1;
int test = 0;
for (int i = 0;i < n-k+1;i++)
{
for (int j = 0;j < k;j++)
{
test = 0;
while (test == 0)
{
if (fx == 1 && start == n - 1)
{
fx = 2;
j = 0;
test = arr[start];
}
else if (fx == 2 && start == 0)
{
fx = 1;
j = 0;
test = arr[start];
}
else if (fx == 1)
{
start++;
test = arr[start];
}
else if (fx == 2)
{
start--;
test = arr[start];
}
}
}
printf("%d\n", arr[start]);
arr[start] = 0;
}
return 0;
}
?
#include <stdio.h>
int main()
{
long long score;
int result = -1;
for (int i = 0;i < 10;i++)
{
score = -1;
while (score > 100 || score < 0)
{
scanf("%lld", &score);
}
if (score >= result)
{
result = score;
}
}
printf("%d", result);
return 0;
}
?
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
long long score;
int result = -1;
int times = 1;
for (int i = 0;i < 10;i++)
{
score = -1;
while (score > 100 || score < 0)
{
scanf("%lld", &score);
}
if (score > result)
{
result = score;
times = 1;
}
else if (score == result)
{
times++;
}
}
for (int i = 0;i < times;i++)
{
printf("%d\n", result);
}
return 0;
}
?
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
long long score;
int max=-1;
int min=101;
float sum;
for (int i = 0;i < 10;i++)
{
score = -1;
while (score > 100 || score < 0)
{
scanf("%lld", &score);
}
if (score > max)max = score;
if (score < min)min = score;
sum += score;
}
sum -= max;
sum -= min;
sum /= 8;
printf("%d\n", min);
printf("%d\n", max);
printf("%.1f\n", sum);
return 0;
}
?
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
int a=1, b=1;
int times = 0;
int arr[1000] = { 0 };
int n = 0;
while (a!=0||b!=0)
{
times = 0;
scanf("%d%d", &a, &b);
if (a == 0 && b == 0)break;
int a1, a2, a3, b1, b2, b3;
a1 = a / 100;
a2 = (a / 10)-a1*10;
a3 = a % 10;
b1 = b / 100;
b2 = (b / 10)-b1*10;
b3 = b % 10;
if (a3 + b3 >= 10)
{
times++;
a2++;
}
if (a2 + b2 >= 10)
{
times++;
a1++;
}
if (a1 + b1 >= 10)
{
times++;
}
arr[n] = times;
n++;
}
for (int i = 0;i < n;i++)
{
printf("%d\n", arr[i]);
}
return 0;
}
?
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int number1;
int number;
double d1, d2,d3;
double d6, d4, d5;
int arr[100] = { 0 };
for (int i = 0;i < n;i++)
{
scanf("%d", &number1);
arr[i] = number1;
}
for (int i = 0;i < n;i++)
{
number = arr[i];
//if (1.0 / number == (1.0 / (number + 1)) + (1.0 / (number * (number * (number + 1)))))printf("yes");
for (int j = (number +1);j <= (2 * number);j++)
{
for (int z = (number * (number + 1));z >= (2 * number);z--)
{
d1 = 1.0 * (j + z) / (j * z);
d3 = 1.0 / number;
if ((d3) == (d1))
{
printf("1/%d=1/%d+1/%d\n", number, z, j);
}
}
}
}
return 0;
}
?
?
?
文章来源:https://blog.csdn.net/weixin_72770922/article/details/135015126
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!