⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ho10_2.c

📁 Software Development in C: A Practical Approach to Programming and Design 软件开发:编程与设计(C))——国外经典教材·计
💻 C
字号:
#include <stdio.h>

int main()
{
	int i;
	int j;
	char tempChar;
	char anArray[100];
	int top;

	// Fill the array.
	for (i=0,tempChar=' ';i<100;i++)
	{
		anArray[i]=tempChar++;
  	}

	for (top=0,tempChar=' ';
		 (tempChar!='q') && (tempChar!='Q');
		 scanf("%c",&tempChar))
	{
		switch (tempChar)
		{
			case 'U':
			case 'u':
				top -= 20-1;
			break;

			case 'D':
			case 'd':
				top += 20-1;
			break;
		}

		if (top<0)
		{
			top=0;
		}
		else if (top >= 100)
		{
			top=100-20;
		}

		if (tempChar != '\n')
		{
			for (i=top,j=0;
				 (i < top+20) && (i < 100);
				 i++,j++)
			{
				printf("Display Line %d",j);
				printf(":  Array element %d: %c\n",
					   i,
					   anArray[i]);
			}
			printf("\nCOMMAND:");
		}
	}
	return (0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -