c语言 ACM 题Description A number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit.For example,the four-digit number 1234 is composed of digits that are non-decreasing.Som
来源:学生作业帮助网 编辑:六六作业网 时间:2025/02/03 19:16:43
c语言 ACM 题Description A number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit.For example,the four-digit number 1234 is composed of digits that are non-decreasing.Som
c语言 ACM 题
Description
A number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit.For example,the four-digit number 1234 is composed of digits that are non-decreasing.Some other four-digit numbers that are composed of non-decreasing digits are 0011,1111,1112,1122,2223.As it turns out,there are exactly 715 four-digit numbers composed of non-decreasing digits.
Notice that leading zeroes are required:0000,0001,0002 are all valid four-digit numbers with nondecreasing digits.
For this problem,you will write a program that determines how many such numbers there are with a specified number of digits.
Input
The first line of input contains a single integer P,(1
c语言 ACM 题Description A number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit.For example,the four-digit number 1234 is composed of digits that are non-decreasing.Som
#include<ctype.h>
#include<stdio.h>
#include<math.h>
main()
{
int i,j,n;
char s;
clrscr();
printf("Please input Number:");
scanf("%d",&n);
printf("\n");
printf("Case #");
for (i=n-1;i>=-n+1;i--)
{
for(j=0;j<=abs(i);j++) printf(" ");
for (j=n-abs(i)-1;j>=-(n-abs(i))+1;j--)
printf("%c",toascii(abs(n-abs(j)-abs(i))+64));
printf("\n");
}
getch();
}