summaryrefslogtreecommitdiff
path: root/C_Programming:_A_Modern_Approach_by_K.N._King/Chapter15.ipynb
blob: 8429721c8091c2fe23c0b4c2a516e9e1d652491b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
 "metadata": {
  "name": "",
  "signature": "sha256:66fb80b57a6473ffca1e8f425382d8ae7bda3cbb5a42b72a09573b1379da5aa8"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 15: Writing Large Programs"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example justify.c, Page 359\n",
      "Other files- word.h, line.h, word.c, line.c"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import textwrap\n",
      "quote2=''\n",
      "quote= ('  C   is quirky, flawed,    and an '\n",
      "        'enormous success.     Although accidents of   history '\n",
      "        ' surely  helped,   it evidently satisfied   a   need '\n",
      "        ''\n",
      "        'for  a   system  implementation   language   efficient '\n",
      "        'enough    to   displace         assembly   language, '\n",
      "        '  yet sufficiently   abstract   and fluent    to describe '\n",
      "        ' algorithms  and    interactions   in a   wide    variety '\n",
      "        'of    environments.'\n",
      "        '                      -- Dennis     M.        Ritchie')\n",
      "for i in quote:\n",
      "    if (len(i)>20):\n",
      "        i=(i[:20] + '*')\n",
      "    quote2=quote2+i\n",
      "quote2=' '.join(quote2.split()) \"\"\"Python has inbuilt functions for removing \n",
      "white spaces and textwrap, justifying text hence reduces the amount of code as required in C\"\"\"\n",
      "quotee= textwrap.fill(quote2)\n",
      "print quotee"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C is quirky, flawed, and an enormous success. Although accidents of\n",
        "history surely helped, it evidently satisfied a need for a system\n",
        "implementation language efficient enough to displace assembly\n",
        "language, yet sufficiently abstract and fluent to describe algorithms\n",
        "and interactions in a wide variety of environments. -- Dennis M.\n",
        "Ritchie\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}