@[Bilion_冰凌帅](/space/show?uid=54372) 友好的~~GUI~~【滑稽】
by Billy●Herrington @ 2018-10-07 20:22:18
@[Bilion_冰凌帅](/space/show?uid=54372)
```
1 1 HH.cpp [Error] 'include' does not name a type
HH.cpp In function 'int count(int*, int)':
44 11 HH.cpp [Error] expected '}' at end of input
```
~~搞事的~~
by 业余门槛 @ 2018-10-07 20:24:11
@[A15174768677](/space/show?uid=136599) 这句去掉再交一次试试
并且你的函数在主程序外定义了一次在主程序里就不用再写一次了
再然后count函数里判断a[i]==-1对的,但是要把a的每一位都先赋值成-1
~~有的我看不懂,代表我初赛阅读程序题凉凉了~~
by A_Đark_Horcrux @ 2018-10-07 21:11:04
我之前那个程序还是有问题的,我刚才调试了一番,现在题目列举的三个输入样例都能得出正确答案,但是还是过不了。呜呜呜
我这回加了注释,麻烦大佬帮看一下,谢谢啦。
```c
#include<stdio.h>
int main()
{
int count(int a[], int n);
printf("input\n");
int a[10],i;
for (i = 0; i < 10; i++)
{
scanf("%d", &a[i]);
}
int ans = count(a, 10);
printf("%d\n", ans);
return 0;
}
int count(int a[], int n)
{
int i,j, flag = 1, ans=0;
for (i = 0; i < n; i++)
{
a[i] = a[i] % 42;
}
for (i = 0; i < n; i++)
{
flag = 1;/*flag为判断标志*/
for (j = i+1; j <= n; j++)/*从当前数开始向后查找,如果有与该数相同的,赋为-1*/
{
if (a[i] == -1)/*如果该数是-1则证明前面有与他相同的数,flag赋为0,跳出循环*/
{
flag = 0; break;
}
if (a[i] == a[j])
{
a[j] = -1;/*从当前数开始向后查找,如果有与该数相同的,赋为-1*/
}
}
if (flag == 1)
{
ans++;
}
}
return ans;
}
```@[Bilion_冰凌帅](/space/show?uid=54372)
by 唐飒 @ 2018-10-07 21:23:35
@[Bilion_冰凌帅](/space/show?uid=54372)
我之前那个程序还是有问题的,我刚才调试了一番,现在题目列举的三个输入样例都能得出正确答案,但是还是过不了。呜呜呜 我这回加了注释,麻烦大佬帮看一下,谢谢啦。
```c
#include<stdio.h>
int main()
{
int count(int a[], int n);
printf("input\n");
int a[10],i;
for (i = 0; i < 10; i++)
{
scanf("%d", &a[i]);
}
int ans = count(a, 10);
printf("%d\n", ans);
return 0;
}
int count(int a[], int n)
{
int i,j, flag = 1, ans=0;
for (i = 0; i < n; i++)
{
a[i] = a[i] % 42;
}
for (i = 0; i < n; i++)
{
flag = 1;/*flag为判断标志*/
for (j = i+1; j <= n; j++)/*从当前数开始向后查找,如果有与该数相同的,赋为-1*/
{
if (a[i] == -1)/*如果该数是-1则证明前面有与他相同的数,flag赋为0,跳出循环*/
{
flag = 0; break;
}
if (a[i] == a[j])
{
a[j] = -1;/*从当前数开始向后查找,如果有与该数相同的,赋为-1*/
}
}
if (flag == 1)
{
ans++;
}
}
return ans;
}
```
by 唐飒 @ 2018-10-07 21:24:36
@[A15174768677](/space/show?uid=136599) 那行 输出input 去掉应该就对了吧
如果是你们老师叫你们加上这行,在OJ上要去掉
by A_Đark_Horcrux @ 2018-10-08 12:40:24