Chinaunix首页 | 论坛 | 博客
  • 博客访问: 184500
  • 博文数量: 28
  • 博客积分: 648
  • 博客等级: 上士
  • 技术积分: 260
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-17 05:33
文章分类

全部博文(28)

文章存档

2012年(1)

2011年(27)

分类: C/C++

2011-09-04 08:08:44

  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>


  4. using namespace std;

  5. int main(){
  6.     double num;
  7.     stringstream s;
  8.     char str[512];
  9.     char c[512];    
  10.     //cout.setf(ios_base::fixed, ios_base::floatfield); fixed-float
  11.     cout<<"Input a number: ";
  12.     cin >>num;
  13.     s << num;
  14.     s >> str;    
  15.     sscanf(str,"%[0-9]",c);
  16.     if(strlen(str)!=strlen(c))
  17.     cout<<num<<" is a decimal number"<<endl;
  18.     else
  19.     cout<<num<<" is an integral number"<<endl;
  20.     return 0;
  21. }
阅读(1876) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~