Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/132.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;钻石控制台输出问题_C++_For Loop_Visual C++_Cin - Fatal编程技术网

C++ C++;钻石控制台输出问题

C++ C++;钻石控制台输出问题,c++,for-loop,visual-c++,cin,C++,For Loop,Visual C++,Cin,我试图让我的for循环输出一个给定用户特定的max和min的菱形,即使是输入也是不允许的。任何想法都将不胜感激。练习并不像我想象的那么顺利 #include <iostream> #include <iomanip> using namespace std; int main() { int rows, count; cout<<"What is the width of the diamond (3 to 21, odd values only):

我试图让我的for循环输出一个给定用户特定的max和min的菱形,即使是输入也是不允许的。任何想法都将不胜感激。练习并不像我想象的那么顺利

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{

int rows, count;

cout<<"What is the width of the diamond (3 to 21, odd values only): ";
cin>>rows;

//Error checking
if(rows < 1 || rows > 25)
    {
        cout<<"Invalid. please enter an odd number from 1 to 25: ";
        cin>>rows;
    }

//Ascending
for (count = 1; count < rows; count += 1)       
    {
        for (int rows = 0; rows < count; rows ++)
        cout<<"*";
        cout<<endl;
    }

//Descending
for (count; count > 0; count -= 1)              
    {
        for (int rows = 0; rows < count; rows ++)
        cout<<"*";
        cout<<endl;
    }


cin.get();
cin.get();

return 0;

}
#包括
#包括
使用名称空间std;
int main()
{
int行,计数;
库特罗斯;
//错误检查
如果(行数<1 | |行数>25)
{
库特罗斯;
}
//上升的
对于(计数=1;计数<行;计数+=1)
{
for(int rows=0;rowscout这执行目标的前半部分-:

for (int stars = 1; stars <= rows; stars+=2)
{
        int padding = rows - stars;
        for (int c = 0; c < padding/2; ++c)
           cout<<" ";
        for (int s = 0; s < stars; ++s)
           cout<<"*";
        cout<<endl;
}

for(int stars=1;stars)我们不会为您做作业。如果您有特定问题,请提问。您需要检查是否有奇怪之处,并且需要在其中添加空格以制作钻石这是一个挑战,而不是作业。