The C Programming Language 2nd Edition Execise5-4 Answer

the C programming language ( kindle 版) C语言最经典教材。英文原版第二版。mobi格式,完美支持kindle。程序员必读 立即下载

Exercise 5-4. Write the function strend(s,t), which returns 1 if the string t occurs at the
end of the string s, and zero otherwise.

简单问题,复习语言。

最直接的想法:

 

//The C Programming Language 2nd Edition Execise5-4 Answer
//by DaNmarner
//http://blog.youkuaiyun.com//DaNmarner
#include<stdio.h>
int strend(char *s,char *t)
{
 char *ps,*pt;
 while (*s != '/0'){
  for(ps = s,pt = t;*ps == *pt;ps++,pt++)
   if(*ps == '/0' || *pt == '/0') break;
  if (*ps == '/0' && *pt == '/0') return 1;
  s++;
 }
 return 0;
}

但其实这个算法效率很低,O(N^2)。下面这个就好多了:

 

//The C Programming Language 2nd Edition Execise5-4 Answer
//by DaNmarner
//http://blog.youkuaiyun.com//DaNmarner

#include<stdio.h>
#include<string.h>
int strend2(char *s,char *t)
{
 int ls = strlen(s);
 int lt = strlen(t);
 if (lt > ls) return 0;
 while(s[--ls] == t[--lt] && lt >= 0);
 if (lt == -1) return 1;
 else return 0;
}

这就是O(n)了~

name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-1391084545775812&dt=1187587170293&lmt=1187587166&format=468x15_0ads_al&output=html&correlator=1187587170273&channel=7913117752&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2FAdministrator%2F%E6%A1%8C%E9%9D%A2%2F优快云%E6%96%87%E7%AB%A0%E9%A1%B6%E9%83%A8%E5%AF%BC%E8%88%AA.htm&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=000000&color_border=FFFFFF&ga_vid=254352278.1187587170&ga_sid=1187587170&ga_hid=2130092920&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=16&u_tz=480&u_java=true" frameborder="0" width="468" scrolling="no" height="15" allowtransparency="allowtransparency">

name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-1391084545775812&dt=1187587040446&lmt=1187587036&format=468x60_as&output=html&correlator=1187587040416&channel=8802996721&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2FAdministrator%2F%E6%A1%8C%E9%9D%A2%2F优快云%E6%96%87%E7%AB%A0%E5%BA%95%E9%83%A8.htm&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=000000&color_border=FFFFFF&ad_type=text&ga_vid=1630047283.1187587040&ga_sid=1187587040&ga_hid=4528641&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=16&u_tz=480&u_java=true" frameborder="0" width="468" scrolling="no" height="60" allowtransparency="allowtransparency">

 
The C programming Language(chm格式完整版) The C programming Language By Brian W. Kernighan and Dennis M. Ritchie. Published by Prentice-Hall in 1988 ISBN 0-13-110362-8 (paperback) ISBN 0-13-110370-9 目录结构: Contents Preface Preface to the first edition Introduction Chapter 1: A Tutorial Introduction Getting Started Variables and Arithmetic Expressions The for statement Symbolic Constants Character Input and Output File Copying Character Counting Line Counting Word Counting Arrays Functions Arguments - Call by Value Character Arrays External Variables and Scope Chapter 2: Types, Operators and Expressions Variable Names Data Types and Sizes Constants Declarations Arithmetic Operators Relational and Logical Operators Type Conversions Increment and Decrement Operators Bitwise Operators Assignment Operators and Expressions Conditional Expressions Precedence and Order of Evaluation Chapter 3: Control Flow Statements and Blocks If-Else Else-If Switch Loops - While and For Loops - Do-While Break and Continue Goto and labels Chapter 4: Functions and Program Structure Basics of Functions Functions Returning Non-integers External Variables Scope Rules Header Files Static Variables Register Variables Block Structure Initialization Recursion The C Preprocessor File Inclusion Macro Substitution Conditional Inclusion Chapter 5: Pointers and Arrays Pointers and Addresses Pointers and Function Arguments Pointers and Arrays Address Arithmetic Character Pointers and Functions Pointer Arrays; Pointers to Pointers Multi-dimensional Arrays Initialization of Pointer Arrays Pointers vs. Multi-dimensional Arrays Command-line Arguments Pointers to Functions Complicated Declarations Chapter 6: Structures Basics of Structures Structures and Functions Arrays of Structures Pointers to Structures Self-referential Structures Table Lookup Typedef Unions Bit-fields Chapter 7: Input and Output Standard Input and Output Formatted Output - printf Variable-length Argument Lists Formatted Input - Scanf File Access Error Handling - Stderr and Exit Line Input and Output Miscellaneous Functions String Operations Character Class Testing and Conversion Ungetc Command Execution Storage Management Mathematical Functions Random Number generation Chapter 8: The UNIX System Interface File Descriptors Low Level I/O - Read and Write Open, Creat, Close, Unlink Random Access - Lseek Example - An implementation of Fopen and Getc Example - Listing Directories Example - A Storage Allocator Appendix A: Reference Manual Introduction Lexical Conventions Syntax Notation Meaning of Identifiers Objects and Lvalues Conversions Expressions Declarations Statements External Declarations Scope and Linkage Preprocessor Grammar Appendix B: Standard Library Input and Output: <stdio.h> File Operations Formatted Output Formatted Input Character Input and Output Functions Direct Input and Output Functions File Positioning Functions Error Functions Character Class Tests: <ctype.h> String Functions: <string.h> Mathematical Functions: <math.h> Utility Functions: <stdlib.h> Diagnostics: <assert.h> Variable Argument Lists: <stdarg.h> Non-local Jumps: <setjmp.h> Signals: <signal.h> Date and Time Functions: <time.h> Implementation-defined Limits: <limits.h> and <float.h> Appendix C: Summary of Changes 立即下载

相关推荐

The C Programming Language and Answer book

C Bible: The.C.Programming.Language.2nd.Edition.pdf TheCAnswerBook.chm

The c programming language.azw3

This ebook is the first authorized digital version of Kernighan and Ritchie’s 1988 classic, The C Programming Language (2nd Ed.). One of the best-selling programming books published in the last fifty years, "K&R" has been called everything from the "bible" to "a landmark in computer science" and it has influenced generations of programmers. Available now for all leading ebook platforms, this concise and beautifully written text is a "must-have" reference for every serious programmer’s digital library. As modestly described by the authors in the Preface to the First Edition, this "is not an introductory programming manual; it assumes some familiarity with basic programming concepts like variables, assignment statements, loops, and functions. Nonetheless, a novice programmer should be able to read along and pick up the language, although access to a more knowledgeable colleague will help."

The Dart Programming Language epub

The Dart Programming Language 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书

TheGoProgrammingLanguage.epub

Go 是一个开源的编程语言,它能让构造简单、可靠且高效的软件变得容易。 Go是从2007年末由Robert Griesemer, Rob Pike, Ken Thompson主持开发,后来还加入了Ian Lance Taylor, Russ Cox等人,并最终于2009年11月开源,在2012年早些时候发布了Go 1稳定版本。现在Go的开发已经是完全开放的,并且拥有一个活跃的社区。

The Swift Programming Language 各版本集合包(epub,mobi,pdf)

Apple最新的编程语言swift官方文档《The Swift Programming Language》的epub,mobi以及pdf 版本,epub 版本为官方英文版,拥有完整的目录,pdf和mobi为epub个人转制版,适合不同设备阅读。 Swift is a new programming language for creating iOS and OS X apps. Swift builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun. Swift’s clean slate, backed by the mature and much-loved Cocoa and Cocoa Touch frameworks, is an opportunity to reimagine how software development works. This book provides: - A tour of the language. - A detailed guide delving into each language feature. - A formal reference for the language.

《the c programming language answer》

还在因为学《the c programming language》,而烦恼吗?还在为课后习题不懂而烦恼吗?那么就来下载这本书吧,会让你有想不到的收获!

epub格式"The C++ Programming Language, 4th Edition"by Bjarne Stroustrup

Bjarne Stroustrup, "The C++ Programming Language, 4th Edition"epub阅读格式版。 内带目录、标签和链接,整体质量非常高,阅读体验比PDF版要好。

The C Programming Language__ answer

The C Programming Language的answer

The Swift Programming Language epub

The Swift Programming Language 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

The Swift Programming Language(pdf和epub两种)

Swift是一种用于iOS和OS X应用的全新编程语言,它建立在最好的C和Objective-C语言中,并且没有C语言的兼容性限制。Swift采用安全的编程模式,增加了现代功能使编程更容易、更灵活、更有趣。Swift背靠成熟且备受宠爱的Cocoa 和 Cocoa Touch框架的支持,这是一个重新构想软件开发的机会。   Swift经过了数年的酝酿,Apple通过改进现有的编译器、调试器和框架结构奠定了Swift的基础,并通过Automatic Reference Counting(ARC)简化了内存管理。Swift的框架建立在坚实的Foundation和Cocoa上,已实现现代化和彻底标准化。 Objective-C本身已经逐步发展到到支持blocks、 collection literals 和modules,使框架采用不中断的现代语言技术。感谢这个基础,我们可以为Apple软件发展的未来引入一种新语言。   对Objective-C开发者来说Swift看起来很熟悉,它具有Objective-C命名参数的可读性和动态对象模型的力量,提供了无缝接入现有Cocoa框架和与Objective-C混编的能力。建立在这个共同点上,Swift引入了许多新的特性、统一的程序和面向对象的语言部分。   Swift对于新程序员是友好的,作为一个具有表现力和娱乐性的脚本语言,它是第一个获得工业品质的系统编程语言。它支持playgrounds,一个允许程序员调试Swift代码并立即看到结果,而无需反复编译运行程序的新功能。   Swift结合了最好的现代语言思维和智慧 - 来自广大的苹果工程师文化。编译器针对性能进行了优化,语言也进行了发展优化,而无需任何牺牲。它的设计从“Hello World”扩展到整个操作系统,这一切使得Swift对于开发者和Apple是一个有意义的投资。   Swift以极好的方式来编写的iOS和OS X应用,并将继续发展与新特性和功能。Swift充满野心,我们已经迫不及待看你能用它创造什么。

The C++ Programming Language(4th) epub

The C++ Programming Language(4th) 英文epub 第4版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书

The Swift Programming Language.epub

The Swift Programming Language.epub ,好东西,非常清晰 ,英文版,使用epub的阅读工具 ,Adobe Digital Editions http://www.adobe.com/products/digital-editions/download.html

the c programming language

epub格式的,可以直接放进电子书里面看,排版一级棒

Brian Kernighan & Dennis Ritchie:The C Programming Language

Brian Kernighan & Dennis Ritchie:The C Programming Language.epub

The Swift Programming Language (Swift 5.0)包括pdf和epub版本

官方最新版本Swift 5.0 包括pdf和epub两个版本,pdf相比epub的好处就是可以使用Apple Pencil写写画画

epub格式原版 Swift Programming Language 苹果Swift编程语言 替代Objective C

苹果官方 The Swift Programming Language 文档 苹果 IOS Swift编程语言 epub格式原版 2014年6月3日发布。

C - StrEnd: Return 1 if the string t occurs at the end of the string s, and zero otherwise

分享一个大牛的人工智能教程。零基础!通俗易懂!风趣幽默!希望你也加入到人工智能的队伍中来!请点击http://www.captainbed.net /* * StrEnd: Return 1 if the string t occurs at the end of the string s, * and zero otherwise. * * StrEnd.c - by FreeMan */ int StrLen(const char *s) { char *p = s; while (

了解➔熟悉➔掌握➔精通 443

ARM Cortex平台NEON指令集优化实战指南

本文为ARM Cortex平台开发者提供了一份全面的NEON指令集优化实战指南。文章从NEON的SIMD架构原理讲起,详细介绍了开发环境搭建、NEON内联函数与自动向量化两种核心编程方法、关键数据类型与指令,并通过图像饱和运算、矩阵乘法等实战案例,深入解析了性能调优技巧与常见避坑指南,旨在帮助开发者充分释放ARM处理器的并行计算潜力。

weixin_29162439的博客 259
上一篇: del.icio.us浅解
下一篇: 彻底投靠Firefox
DaNmarner
博客等级 码龄21年 27粉丝 91原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值