我想弄清楚这段代码有什么问题。选择正确的数字
我试图做一个C程序,只扫描没有重复的数字,但它不能很好地工作。这是代码:
#include<ctype.h>
#include<string.h>
int main (void)
{
//training for sorting tables
int tab[100] , *p , n , bb=0 ;
p=tab ;
printf("enter how many numbers you want to type \n");
scanf("%d",&n);
printf("enter the numbers one by one okay");
for(int i=0; i<n ; i++)
{
printf("number %d \n", i+1);
scanf("%d",*(p+i));
for(int x=0 ; x<= i ; x++)
{
if(*(p+x) == *(p+n))
{
bb=1;
}
}
if (bb == 1)
{
i-- ;
}
}
for(int a=0 ; a<n ; a++)
printf("%d \n", *(p+a));
}
此外,请修复您的格式。代码真的很难阅读,因为缩进是混乱的地方。 – fuz
@SouravGhosh它应该是''对于标准IO –
@Fuzxxi'ctype.h'是一个C头。 'cctype'是'ctype.h'的C++头文件。 –