注册 登录
编程论坛 C++教室

命令行输出时异常现象

xhl124 发布于 2013-02-13 14:37, 231 次点击
只有本站会员才能查看附件,请 登录

// 7777777.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<iostream>
#include<iomanip>
using std::cin;
using std::cout;
using std::endl;
using std::setw;
using std::setiosflags;


int _tmain(int argc, _TCHAR* argv[])
{
    cout<<"     输入一个小于20000的整数,将输出所有与七有关的数"<<endl;
    int n=0;   //所输入的整数
    int i=1,j=0;
    cin>>n;
    for( i=7;i<=n;i++)
    {
        
        if(i%7==0)
        {cout<<setw(5)<<i;  j++;
               continue;}
        else
        {
        int k=i;
        while(k)
        {
            if(k%10==7)
            {cout<<setw(5)<<i;  j++;
            }
            k=k/10;
        }
        }
        if(j%10==0&&j>=10)
            cout<<endl;

    }cout<<endl;
    return 0;
}
1 回复
#2
peach54602013-02-17 11:25
1,把你的代码风格写好
2,建议你画程序流程图吧
        if(j%10==0&&j>=10)
            cout<<endl;
放的位置不对
1