CQUPT计算机复试2013年a卷代码题

CQUPT计算机考研2013真题a卷代码题

搬运请注明出处

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
#include <stack>
#include <queue>
#include <random>
#include <set>
using namespace std;
#define N 100
// 13a--1
// int main(int argc, char const *argv[])
// {
//     int x;
//     float f;
//     scanf("%d", &x);
//     if (x < 0)
//     {
//         f = (x + 1) * (x + 1) + 2 * x + 1.0 / x;
//     }
//     else
//     {
//         f = (float)sqrt(x);
//     }
//     printf("%f\n", f);
//     return 0;
// }

// 13a--2
// int main(int argc, char const *argv[])
// {
//     int n, count = 0, x;
//     printf("Please input n=");
//     scanf("%d", &n);
//     printf("%d*%d*%d=", n, n, n);
//     x = n * (n - 1) + 1; // keypoint
//     while (count < n)
//     {
//         printf("%d", x);
//         x = x + 2;
//         count++;
//         if (count < n )
//         {
//             printf("+");
//         }
//     }
//     return 0;
// }

// 13a--3
void Count(char *words, int *count)
{
    char *s;
    s = words;
    int len = strlen(s);
    while (*s)
    {
        if (*s != ' ' && *s != '.' && *s != ',' && *s != '?' && *s != '!')
        {
            *count += 1;
            //循环到本单词结束
            while (*s != ' ' && *s != '.' && *s != ',' && *s != '?' && *s != '!')
            {
                s++;
            }
        }
        s++;
    }
}
int main(int argc, char const *argv[])
{
    printf("请输入一段英文:");
    char words[100];
    gets(words);
    int n = 0;
    Count(words, &n);
    printf("%d", n);
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值