Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays C程序,使用break语句打印出数组中不重复的数字_Arrays_C_For Loop_If Statement_Break - Fatal编程技术网

Arrays C程序,使用break语句打印出数组中不重复的数字

Arrays C程序,使用break语句打印出数组中不重复的数字,arrays,c,for-loop,if-statement,break,Arrays,C,For Loop,If Statement,Break,所以我在搜索一个程序,它可以打印出数组中不重复的数字,这个程序很好,但是我不能理解break语句部分到底发生了什么,所以请有人解释一下发生了什么,因为我找不到它,下面是代码 #include<stdio.h> int main(void){ int n; printf("enter a value for n: "); scanf("%d",&n); int T[n]; int j; printf("fill in th

所以我在搜索一个程序,它可以打印出数组中不重复的数字,这个程序很好,但是我不能理解break语句部分到底发生了什么,所以请有人解释一下发生了什么,因为我找不到它,下面是代码

#include<stdio.h>
int main(void){

int n;
printf("enter a value for n: ");
scanf("%d",&n);
int T[n];
int j;  
printf("fill in the array: \n");
for(int i=0 ; i<n ; i++)
{
    printf("enter value %d: ",i+1);
    scanf("%d",&T[i]);
}   
for(int i=0 ; i<n ; i++)
{
    printf("%d ",T[i]);
}


//---------------------------------------------------------------------//

        
printf("the non repeated elements are: \n");
for(int i=0 ; i<n ; i++)
{
    for( j=0 ; j<n ; j++)
    {
        if(T[i]==T[j] && i!=j)
        {
            break;
        }
            
            
    }
    if(j==n)
    {       
    printf("%d ",T[i]);         
    }
}   
return 0;
}
#包括
内部主(空){
int n;
printf(“输入n:”的值);
scanf(“%d”和“&n”);
int T[n];
int j;
printf(“填入数组:\n”);

for(inti=0;i内部循环
for(j=0;jd)这是否回答了您的问题?⟼请记住,保持代码尽可能有条理是非常重要的,尤其是在学习和询问堆栈溢出问题时。这有助于沟通结构,更重要的是,还有助于我们快速找到问题的根源,而无需花费大量时间试图解译发生的情况。
for( j = 0 ; j < n && (T[i] != T[j] || i == j) ; j++)
{
    // empty
}