本文介绍了如何在直线上移动角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在c ++上创建一个简单的编码项目。我需要在y = mx + c中移动*字符。我写了一杯编码线来生成直线。现在我必须在这条道路上移动它。 PLZ帮助我.....



我尝试过:



I have to make a simple coding project on c++. i need to move "*" character in y=mx+c. i wrote a cup of coding lines to generate straight lines. now i have to move this in that path. plz help me.....

What I have tried:

#include <iostream>
#include <math.h>
#include<Windows.h>
using namespace std;

int pth (int x)  {
    return -1*x+1;
}

int main()  {
    int i,j,y;
    for (int x=-10;x <= 10;x++)  {
        for ( i=-10;i <= x;i++)  {
            if (i==x) {
                y=pth(x);
               // cout<<"x=";
                //cout<<x;
                //cout<<"y=";
                //cout<<y;

                for(j=-10;j<=y;j++) {
                   if(j==y)
                        cout << "*";
                    else
                        cout << " ";
                }
            }
        }
        cout << "\n";
system("cls");
Sleep(20);
    }
    cin.get();
    return 0;
 }

推荐答案



这篇关于如何在直线上移动角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:13