3D FPS

1234567890

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  57 Posts :: 2 Stories :: 57 Comments :: 0 Trackbacks

常用链接

留言簿(10)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜


 1 //输入一串字符串,将连接着的数字输出来,并统计有多少个整数
 2 #include <stdio.h>
 3 #include <tchar.h>
 4 #include <process.h>
 5 #include <string.h>
 6 #include <stdlib.h>
 7 
 8 
 9 int _tmain(int argc, _TCHAR* argv[])
10 {
11     char szText[2048];
12     scanf("%s",szText);
13 
14     printf("你输入的是%s\n",szText);
15 
16     int a[2048];
17     int aNum = 0;
18     int nLenText = strlen(szText);
19     int nStartNum = -1,nEndNum = -1;//数字起始位置
20     char *pStartChar = NULL, *pEndChar = NULL;
21     char szTempBuf[2048];
22     for(char *= szText; ; p++)
23     {
24         char aChar = *p;
25         if(( aChar >= '0'&& (aChar <= '9'))
26         {
27             if( pStartChar == NULL)
28             pStartChar = p;
29 
30         }
31         else if(( aChar < '0'|| (aChar > '9'))
32         {
33             pEndChar = p;
34             
35             //找到一组数字
36             if(pStartChar != 0)
37             {
38                 int nBufLen = pEndChar-pStartChar;
39                 memcpy(szTempBuf,pStartChar,nBufLen);
40                 szTempBuf[nBufLen] = 0;
41                 int nNum = atoi(szTempBuf);
42                 a[aNum]= nNum;
43                 aNum++;
44             }
45             pStartChar = NULL;
46             if(*== 0)
47                 break;
48         }
49         if(*== 0)
50             break;
51 
52         
53     }
54 
55     printf("共有%d个整数\n",aNum);
56     for(int i = 0; i < aNum; i++)
57     {
58         printf("%d  \n",a[i]);
59     }
60 
61     getchar();
62     system("pause");
63 
64     return 0;
65 }
66 
67 
posted on 2013-04-23 11:45 DK_jims 阅读(353) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理