[Functions]D. Liang 5.12 Displaying characters.c

Description

Prints the characters between ch1 and ch2 (including ch1 and ch2) sorting by ASCII value with the specified numbers per line.

Input

The input contains one single line, consists of ch1, ch2 and a positive integer n (1 <= n <= 10) denoting the number of characters per line.

Output

The characters between ch1 and ch2 with the specified numbers per line.

Sample Input

2 z 7

Sample Output

2345678
9:;<=>?
@ABCDEF
GHIJKLM
NOPQRST
UVWXYZ[
\]^_`ab
cdefghi
jklmnop
qrstuvw
xyz
//   Date:2020/3/28
//   Author:xiezhg5
#include <stdio.h>
int main(void)
{
	char ch1,ch2;
	int n,i,a,b,temp,count=0;
	scanf("%c %c %d",&ch1,&ch2,&n);
	a=(int)(ch1);
	b=(int)(ch2);
	if(a>b)
	{
		temp=a;
		a=b;
		b=temp;
	}
	for(i=a;i<=b;i++)
	{
		printf("%c",i);
		count++; 
		if(count%n==0)
		printf("\n");
	}
	return 0;
}

Pay attention to the comparison of the number of inputs to ensure the output. Otherwise:
在这里插入图片描述

发布了131 篇原创文章 · 获赞 94 · 访问量 2937

猜你喜欢

转载自blog.csdn.net/qq_45645641/article/details/105169406