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;
}
这篇文章包含了三道CQUPT计算机考研2013年的A卷代码题目,涉及条件判断、数列生成和单词计数等编程问题。第一题计算平方根,第二题打印特定序列,第三题统计英文单词数量。
113

被折叠的 条评论
为什么被折叠?



