|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <iostream>
- #include<conio.h>
- using namespace std;
- int max = 1024;
- int main()
- {
- char flag=0,tempc;
- int i = 0;
- int tempi1=0,tempi2=0;
- while ((tempc = _getch())&& (i < max)) {
- // printf("%c", tempc);
- cout << tempc;
- if ((tempc > '0') && (tempc < '9')) {
- tempi2 = tempi2 * 10 + (tempc - '0');
- flag = 1;
- }
- else {
- if (flag) {
- tempi1 += tempi2;
- tempi2 = 0;
- flag = 0;
- }
- if (tempc == 13)break;
- }
- }
- // printf("\n%d\n",tempi1);
- cout << endl << tempi1 << endl;
- return 0;
- }
复制代码
很久没有写过c了,一直在写javascript,c生疏了。
我是从c入门编程的,后来写web前端开发,感觉自己也有点面向对象编程的经验了吧(心虚),于是找到了小甲鱼的c++教程看。这是在p2的结尾的一个作业。 |
|