⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdsum.cpp

📁 C++&datastructure书籍源码,以前外教提供现在与大家共享
💻 CPP
字号:
#include <iostream>#include <fstream>              // for ifstream#include <cstdlib>              // for exit#include <string>using namespace std;#include "strutils.h"           // for atoi#include "clockt.h"#include "prompt.h"// reads file containing data for a cd in format below (one line/track)//        min:sec title // and sums all track timesint main(){    ifstream input;    string filename = PromptString("enter name of data file: ");    input.open(filename.c_str());    if (input.fail())    {   cerr << "could not open file " << filename << endl;        exit(0);    }      string minutes,          // # of minutes of track           seconds,          // # of seconds of track           title;            // title of track    ClockTime total(0,0,0);  // total of all times        while (getline(input,minutes,':') &&           getline(input,seconds,' ') &&           getline(input,title))               // reading line ok    {   ClockTime track(atoi(seconds.c_str()),atoi(minutes.c_str()),0);        cout << track << " " << title << endl;        total += track;    }    cout << "------------------------------" << endl;    cout << "total = " << total << endl;    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -