91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 10KB
    文件類型: .gz
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-05-18
  • 語言: 其他
  • 標簽: cs50.c??cs50.h??

資源簡介

網易公開課 哈佛大學 CS50的必要文件

資源截圖

代碼片段和文件信息

/***************************************************************************
?*CS50?Library?3.0
?*
?*?https://manual.cs50.net/Library
?*
?*?Glenn?Holloway?
?*?David?J.?Malan?
?*
?*?based?on?Eric?Roberts‘?genlib.c?and?simpio.c.
?*
?*?Creative?Commons?Attribution-NonCommercial-ShareAlike?3.0?Unported?License
?*?http://creativecommons.org/licenses/by-nc-sa/3.0/
?***************************************************************************/

#include?
#include?
#include?

#include?“cs50.h“


/*
?*?Reads?a?line?of?text?from?standard?input?and?returns?the?equivalent
?*?char;?if?text?does?not?represent?a?char?user?is?prompted?to?retry.
?*?Leading?and?trailing?whitespace?is?ignored.??If?line?can‘t?be?read
?*?returns?CHAR_MAX.
?*/

char
GetChar(void)
{
????//?try?to?get?a?char?from?user
????while?(true)
????{
????????//?get?line?of?text?returning?CHAR_MAX?on?failure
????????string?line?=?GetString();
????????if?(line?==?NULL)
????????????return?CHAR_MAX;

????????//?return?a?char?if?only?a?char?(possibly?with
????????//?leading?and/or?trailing?whitespace)?was?provided
????????char?c1?c2;
????????if?(sscanf(line?“?%c?%c“?&c1?&c2)?==?1)
????????{
????????????free(line);
????????????return?c1;
????????}
????????else
????????{
????????????free(line);
????????????printf(“Retry:?“);
????????}
????}
}


/*
?*?Reads?a?line?of?text?from?standard?input?and?returns?the?equivalent
?*?double?as?precisely?as?possible;?if?text?does?not?represent?a
?*?double?user?is?prompted?to?retry.??Leading?and?trailing?whitespace
?*?is?ignored.??For?simplicity?overflow?and?underflow?are?not?detected.
?*?If?line?can‘t?be?read?returns?DBL_MAX.
?*/

double
GetDouble(void)
{
????//?try?to?get?a?double?from?user
????while?(true)
????{
????????//?get?line?of?text?returning?DBL_MAX?on?failure
????????string?line?=?GetString();
????????if?(line?==?NULL)
????????????return?DBL_MAX;

????????//?return?a?double?if?only?a?double?(possibly?with
????????//?leading?and/or?trailing?whitespace)?was?provided
????????double?d;?char?c;
????????if?(sscanf(line?“?%lf?%c“?&d?&c)?==?1)
????????{
????????????free(line);
????????????return?d;
????????}
????????else
????????{
????????????free(line);
????????????printf(“Retry:?“);
????????}
????}
}


/*
?*?Reads?a?line?of?text?from?standard?input?and?returns?the?equivalent
?*?float?as?precisely?as?possible;?if?text?does?not?represent?a?float
?*?user?is?prompted?to?retry.??Leading?and?trailing?whitespace?is?ignored.
?*?For?simplicity?overflow?and?underflow?are?not?detected.??If?line?can‘t
?*?be?read?returns?FLT_MAX.
?*/

float
GetFloat(void)
{
????//?try?to?get?a?float?from?user
????while?(true)
????{
????????//?get?line?of?text?returning?FLT_MAX?on?failure
????????string?line?=?GetString();
????????if?(line?==?NULL)
????????????return?FLT_MAX;

????????//?return?a?float?if?only?a?float?(possibly?with
????????//?leading?and/or?trailing?whitespace)?was?provided
????????char

評論

共有 條評論