简答题 C++
题号 #2657831

编写一程序,将C++源程序每行前加上行号与一个空格。

进入在线模考

参考答案

暂无

答案解析

#include<iostream>
#include<fstream>
using namespace std;
int main(){
    int i=1;
    char c[1000];
    ifstream ifile("D:\\10_4_3.cpp");
    ofstream ofile("D:\\r10_4_3.cpp");
    while(!ifile.eof()){
        ofile<<i++<<": ";
        ifile.getline(c,999);
        ofile<<c<<endl;
    }
    ifile.close();
    ofile.close();
    return 0;
}

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考