一个数组(在1到50的范围内)取其中6个数,并且不重复呢,请求帮助


#include<stdio.h>

int main()
{
int a[6] = { 0 };
printf("输入6个数字(1-50):");
for (int i = 0; i < 6; i++)
        scanf_s("%d", &a[i]);

//后面不知道该是用什么内容,是用
}

望采纳!谢谢

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
    int a[50],b[6],i=0,j,k,r;
    for(k=0; k <50; k++){
        a[k] = k;
    }
    srand((int)time(0));   //用当前时间作为随机种子 
    while(i<6)
    {
        r=rand() % 50 ;  //生成一个1-50的随机数 
        for(j=i;j>=0;j--)
        {
            if(r==b[j])     //与之前已存的随机数比较 
                break;
        }
        if(j<0)             //没有重复即保存到数组中 
        {
            b[i]=r;
            i++;
        }
    }
    for(int count = 0; count <6; count++)
        printf("%d\n", b[count]);
    
    return 0;
}

img