f1501.cpp
来自「it is a usefull thing」· C++ 代码 · 共 19 行
CPP
19 行
//=====================================
// f1501.cpp
// exit when meet an error
//=====================================
#include<fstream>
#include<iostream>
#include<cmath>
using namespace std;
//-------------------------------------
void fn(){
ifstream in("abc.txt");
if(!in){ cout<<"Error: open file failure.\n"; exit(1); }
for(int a; in>>a; cout<<sqrt(a*1.0)<<"\n")
if(a<0){ cout<<"Error: read in illegle data.\n"; exit(1); }
}//------------------------------------
int main(){ fn(); }
//=====================================
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?