commit 5a3cc2ca160febcfc5fc81eb508016154cce2510 from: jrmu date: Sun Jan 25 02:07:46 2026 UTC Add solutions for 1-19 commit - 780d1efacde062921b1045a3f5f84bf54f7ab231 commit + 5a3cc2ca160febcfc5fc81eb508016154cce2510 blob - /dev/null blob + cc674d1201c2d70142a3a85a27bd0bf20d71df14 (mode 644) --- /dev/null +++ 1-19-output @@ -0,0 +1,29 @@ +INPUT: + +It would be thought a hard Government that should tax its People +one-tenth Part of their _Time_, to be employed in its Service. But +_Idleness_ taxes many of us much more, if we reckon all that is spent +in absolute _Sloth_, or doing of nothing, with that which is spent in +idle Employments or Amusements, that amount to nothing. _Sloth_, by +bringing on Diseases, absolutely shortens Life. _Sloth, like Rust, +consumes faster than Labor wears; while the used key is always bright, +as Poor Richard says. But dost thou love Life, then do not squander +Time, for that's the stuff Life is made of, as Poor Richard_ says. How +much more than is necessary do we spend in sleep, forgetting that _The +sleeping Fox catches no Poultry_, and that _There will be sleeping +enough in the Grave_, as _Poor Richard_ says. + +OUTPUT: + +elpoeP sti xat dluohs taht tnemnrevoG drah a thguoht eb dluow tI¿»ï +tuB .ecivreS sti ni deyolpme eb ot ,_emiT_ rieht fo traP htnet-eno +tneps si taht lla nokcer ew fi ,erom hcum su fo ynam sexat _sseneldI_ +ni tneps si hcihw taht htiw ,gnihton fo gniod ro ,_htolS_ etulosba ni +yb ,_htolS_ .gnihton ot tnuoma taht ,stnemesumA ro stnemyolpmE eldi +,tsuR ekil ,htolS_ .efiL snetrohs yletulosba ,sesaesiD no gnignirb +,thgirb syawla si yek desu eht elihw ;sraew robaL naht retsaf semusnoc +rednauqs ton od neht ,efiL evol uoht tsod tuB .syas drahciR rooP sa +woH .syas _drahciR rooP sa ,fo edam si efiL ffuts eht s'taht rof ,emiT +ehT_ taht gnittegrof ,peels ni dneps ew od yrassecen si naht erom hcum +gnipeels eb lliw erehT_ taht dna ,_yrtluoP on sehctac xoF gnipeels +.syas _drahciR rooP_ sa ,_evarG eht ni hguone blob - /dev/null blob + 3765955a0b0ef9ad9a407eb16f0ea1a71657817b (mode 644) --- /dev/null +++ 1-19-text @@ -0,0 +1,12 @@ +It would be thought a hard Government that should tax its People +one-tenth Part of their _Time_, to be employed in its Service. But +_Idleness_ taxes many of us much more, if we reckon all that is spent +in absolute _Sloth_, or doing of nothing, with that which is spent in +idle Employments or Amusements, that amount to nothing. _Sloth_, by +bringing on Diseases, absolutely shortens Life. _Sloth, like Rust, +consumes faster than Labor wears; while the used key is always bright, +as Poor Richard says. But dost thou love Life, then do not squander +Time, for that's the stuff Life is made of, as Poor Richard_ says. How +much more than is necessary do we spend in sleep, forgetting that _The +sleeping Fox catches no Poultry_, and that _There will be sleeping +enough in the Grave_, as _Poor Richard_ says. blob - /dev/null blob + 316f47d05d2ce95d0e60f80b328dd2b059e2f7ef (mode 644) --- /dev/null +++ 1-19.c @@ -0,0 +1,58 @@ +/* 1-19 Write a function reverse(s) that reverses the character string s. Use + it to write a program that reverses its input a line at a time. */ + +#include + +#define MAXLINE 1000 /* maximum input line size */ + +int getlin(char line[], int maxline); +void reverse(char s[]); +int length(char s[]); + +int main() { + int len; /* current line length */ + char line[MAXLINE]; /* current input line */ + + while ((len = getlin(line, MAXLINE)) > 0) { + reverse(line); + printf("%s", line); + } + return 0; +} + +/* getlin: read a line into s, return length */ +int getlin(char s[], int lim) { + int c, i; + + for (i=0; i + +#define MAXLINE 1000 /* maximum input line size */ + +int getlin(char line[], int maxline); +void reverse(char s[]); +int length(char s[]); + +int main() { + int len; /* current line length */ + char line[MAXLINE]; /* current input line */ + + while ((len = getlin(line, MAXLINE)) > 0) { + reverse(line); + printf("%s", line); + } + return 0; +} + +/* getlin: read a line into s, return length */ +int getlin(char s[], int lim) { + int c, i; + + for (i=0; i