欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

[C语言] n个不同的数可组成多少个不同的三位数

程序员文章站 2022-05-18 14:32:21
#include int main() { int i = 0, j = 0, k = 0; int s = 0, count = 0...
#include<stdio.h>
 
int main()
{
    int i = 0, j = 0, k = 0;
    int s = 0, count = 0, n = 0;
    printf("请输入个数:");
    scanf_s("%d", &n);
    for (i = 1; i <= n;i++)
        for (j = 1; j <= n; j++)
            for (k = 1; k <= n; k++)
            {
                s = i * 100 + j * 10 + k;
                count++;
                printf("%d ", s);
            }
            printf("\n");
            printf("count=%d\n",count);
            system("pause");
    return 0;
}