代码拉取完成,页面将自动刷新
#define _CRT_SECURE_NO_WARNINGS 1
//BC125 序列中整数去重
#include <stdio.h>
int main()
{
int n = 0;
int m = 0;
int i = 0;
int c = 0;
int count = 0;
int arr1[1000] = { 0 };
int arr2[1000] = { 0 };
scanf("%d", &n);
int k = n;
while (k--)
{
scanf("%d", &m);
arr1[i] = m;
i++;
}
for (int i = 0; i < n; i++)
{
count = 0;
for (int j = 0; j <= i; j++)
{
if (arr1[i] == arr2[j])
{
count++;
break;
}
}
if (count == 0)
{
arr2[c] = arr1[i];
c++;
}
}
for (int z = 0; z < c; z++)
printf("%d ", arr2[z]);
return 0;
}
//BC126 小乐乐查找数字
#include <stdio.h>
int main()
{
int n = 0;
int m = 0;
int i = 0;
int s = 0;
int count = 0;
int arr[100] = { 0 };
scanf("%d", &n);
int k = n;
while (k--)
{
scanf("%d", &m);
arr[i] = m;
i++;
}
scanf("%d", &s);
for (int j = 0; j < n; j++)
{
if (arr[j] == s)
count++;
}
printf("%d", count);
return 0;
}
//BC127 筛选法求素数
#include <stdio.h>
int main()
{
int n = 0;
int s = 0;
int count = 0;
int arr[100] = { 0 };
while (~scanf("%d", &n))
{
for (int i = 2; i <= n; i++)
{
count = 0;
for (int j = 2; j <= i / 2; j++)
{
if (i % j == 0)
{
count++;
break;
}
}
if (count == 0)
{
arr[s] = i;
s++;
}
}
for (int i = 0; i < s; i++)
printf("%d ", arr[i]);
printf("\n%d", n - 1 - s);
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。