第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

vc++的cctype頭文件里有isdigit這個函數(shù),是判斷輸入是不是數(shù)字嗎?

vc++的cctype頭文件里有isdigit這個函數(shù),是判斷輸入是不是數(shù)字嗎?

C++
精慕HU 2023-03-18 17:13:27
#include <iostream>#include <cctype>int main(){using namespace std;int ch;double tvarps;cout << "your tvarp: " << endl;while (cin >> ch && ch > 0 ){if(ch <= 5000 && ch >0)  tvarps = 0.0;else if(ch > 5000 && ch <= 15000)tvarps = ch * 0.1;  else if(ch > 15000 && ch <=35000 )tvarps = (ch - 15000)*0.15 + 1000;else if(ch > 35000)tvarps = (ch - 35000)*0.2 + 4000;cout << "tvarps: " << tvarps << endl;}return 0;}
查看完整描述

1 回答

?
瀟瀟雨雨

TA貢獻1833條經(jīng)驗 獲得超4個贊

在while前加char temp[200];
把while(...)改成while(cin>>temp);
循環(huán)里第一行寫if (!isdigit(temp))break;
第二行寫ch = atoi(temp); //把字符串變成整數(shù)

以下是我做的isdigit(),僅供參考
bool isdigit(char *buf)
{
int t = 0;
if (buf[t] == '-' || buf[t] == '+')
if (buf[1] != '\0')
t ++;
for (;buf[t] != '\0'; t ++)
if (buf[t] < '0' || buf[t] > '9')
return false;
return true;
}

查看完整回答
反對 回復(fù) 2023-03-21
  • 1 回答
  • 0 關(guān)注
  • 114 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號