练习3.奔跑的字母

版权声明:此文章为作者筱睿_原创文章,转载请附上博客链接 https://blog.csdn.net/qq_43756486/article/details/86681223

奔跑的字母

其实就是让字母从左向右移动

思路

很简单,就是输出,然后延迟1秒,清屏,第i秒在字母前面输入i个空格,继续循环延迟清屏

代码

#include<iostream>
#include<windows.h>
using namespace std;
int main(){
	int a,b,c;
	cout<<"请输入你要移动的步数"; 
	cin>>c;
	a=0;
	while(a<c)					//while(a)控制移动步数
	{system("cls");				//清屏
	 b=1;
	 	while(b<=a)				//while(b)控制输出空格
	 	{cout<<" ";
		 b=b+1; 					//每向后移动一步就多打印一个空格
	 	}
	 cout<<"字母";				
	 Sleep(500);
	 a=a+1;
	} 
	system("pause");
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/qq_43756486/article/details/86681223
3.