文章目录
- 题解1 | # 实践出真知
- 题解2 | # 我是大V
- 题解3 | # 有容乃大
- 题解4 | # 牛牛学说话之-整数
- 题解5 | # Hello Nowcoder
- 题解6 | # 小飞机
- 题解7 | # 缩短二进制
- 题解8 | # 十六进制转十进制
- 题解9 | # printf的返回值
- 题解10 | # 成绩的输入输出
- 题解11 | #学生基本信息输入输出#
- 题解12 | #字符圣诞树#
- 题解13 | #ASCII码#
- 题解14 | # 出生日期输入输出
- 题解15 | # 按照格式输入并交换输出
- 题解16 | # 字符转ASCII码
- 题解17 | # 计算表达式的值
- 题解18 | # 计算带余除法
- 题解19 | # 反向输出一个四位数
- 题解20 | # kiki算数
- 题解21 | # 浮点数的个位数字
- 题解22 | # 你能活多少秒
- 题解23 | # 时间转换
- 题解24 | # 总成绩和平均分计算
- 题解25 | # 计算体重指数
- 题解26 | # 计算三角形的周长和面积
- 题解27 | # 计算球体的体积
- 题解28 | # 大小写转换
- 题解29 | # 2的n次方计算
- 题解30 | # KIKI喝酸奶
- 题解31 | # 发布信息
- 题解32 | # 输出学生信息
- 题解33 | #计算平均成绩
- 题解34 | # 进制A+B
- 题解35 | # 判断字母
- 题解36 | # 健康评估
- 题解37 | # 网购
- 题解38 | # 变种水仙花数
- 题解39 | # 争夺前五名
- 题解40 | # 竞选社长
- 题解41 | # 你是天才吗?
- 题解42 | # 完美成绩
- 题解43 | # 及格分数
- 题解44 | # 判断整数奇偶性
- 题解45 | # 最高分数
- 题解46 | # 判断是元音还是辅音
- 题解47 | # 判断是不是字母
- 题解48 | # 字母大小写转换
- 题解49 | # 判断两个数的大小关系
- 题解50 | # 计算单位阶跃函数
- 题解51| # 三角形判断
- 题解52| # 衡量人体胖瘦程度
- 题解53| # 计算一元二次方程
- 题解54| # 获得月份天数
- 题解55| # 简单计算器
- 题解56| # 线段图案
- 题解57| # 正方形图案
- 题解58| # 直角三角形图案
- 题解59| # 翻转直角三角形图案
- 题解60| # 带空格直角三角形图案
题解1 | # 实践出真知
链接:https://www.nowcoder.com/practice/9273504dbe6f4c5a92b75854faca5f45
#include <stdio.h>
int main()
{
printf("Practice makes perfect!");
return 0;
}
题解2 | # 我是大V
链接:https://www.nowcoder.com/practice/5c329570ba034871a96299df21e80e51
#include <stdio.h>
int main() {
printf("v v\n");
printf(" v v\n");
printf(" v\n");
return 0;
}
题解3 | # 有容乃大
链接:https://www.nowcoder.com/practice/4712159bbc15417086d40d6c6ff94fee
#include <stdio.h>
int main() {
printf("The size of short is %d bytes.\n",sizeof(short));
printf("The size of int is %d bytes.\n",sizeof(int));
printf("The size of long is %d bytes.\n",sizeof(long));
printf("The size of long long is %d bytes.\n",sizeof(long long));
return 0;
}
题解4 | # 牛牛学说话之-整数
链接:https://www.nowcoder.com/practice/df9ee533ef9544bfa382203c812d9b55
#include <stdio.h>
int main()
{
int num = 0;
scanf("%d",&num);
printf("%d\n",num);
return 0;
}
题解5 | # Hello Nowcoder
链接: https://www.nowcoder.com/practice/6dd1bc8539db4b7199f4972a5dc14bd2
#include <stdio.h>
int main()
{
printf("Hello Nowcoder!\n");
return 0;
}
题解6 | # 小飞机
链接:https://www.nowcoder.com/practice/5cd9598f28f74521805d2069ce4a108a
#include <stdio.h>
int main()
{
printf(" **\n");
printf(" **\n");
printf("************\n");
printf("************\n");
printf(" * *\n");
printf(" * *\n");
return 0;
}
#include <stdio.h>
int main()
{
printf(" ** \n");
printf(" ** \n");
printf("************\n");
printf("************\n");
printf(" * * \n");
printf(" * * \n");
return 0;
}
#include <stdio.h>
int main()
{
printf(" ** \n ** \n************\n************\n * * \n * * \n");
return 0;
}
题解7 | # 缩短二进制
链接:https://www.nowcoder.com/practice/4ffcc9f206b949ddb057ee0099b34d51
#include <stdio.h>
int main()
{
printf("0%o 0X%X\n",1234,1234);
return 0;
}
题解8 | # 十六进制转十进制
链接:https://www.nowcoder.com/practice/33e148570d5c4e728116e2f861638c9c
#include <stdio.h>
int main() {
printf("%15d\n",0xABCDEF);
return 0;
}
题解9 | # printf的返回值
链接:https://www.nowcoder.com/practice/a19ef1d8e55c4cc786f11cbf6b2fde61
#include <stdio.h>
int main() {
printf("\n%d\n",printf("Hello world!"));
return 0;
}
题解10 | # 成绩的输入输出
链接:https://www.nowcoder.com/practice/0f5d9bfcd63b47fda2052a583b1fbd1f
#include <stdio.h>
int main()
{
int score[3]={0};
scanf("%d %d %d",&score[0],&score[1],&score[2]);
printf("score1=%d,score2=%d,score3=%d\n",score[0],score[1],score[2]);
return 0;
}
#include <stdio.h>
int main()
{
int score1 = 0;
int score2 = 0;
int score3 = 0;
scanf("%d %d %d", &score1, &score2, &score3);
printf("score1=%d,score2=%d,score3=%d\n", score1, score2, score3);
return 0;
}
#include <stdio.h>
int main()
{
int score[3] = { 0 };
int i = 0;
for (i = 0; i < 3; i++)
{
scanf("%d", &score[i]);
}
printf("score1=%d,score2=%d,score3=%d\n", score[0], score[1], score[2]);
return 0;
}
题解11 | #学生基本信息输入输出#
链接:https://www.nowcoder.com/practice/eb49750ef0de47168c21761de086d97c
#include <stdio.h>
int main()
{
int id = 0;
float c_score =0.0;
float math_score = 0.0;
float english_score = 0.0;
scanf("%d;%f,%f,%f",&id,&c_score,&math_score,&english_score);
printf("The each subject score of No. %d is %.2f, %.2f, %.2f.",id,c_score,math_score,english_score);
return 0;
}
题解12 | #字符圣诞树#
链接:https://www.nowcoder.com/practice/0fae60c3b5c64699b7c0f031c2187dde
#include <stdio.h>
int main()
{
char ch = '\0';
scanf("%c",&ch);
int i = 0;
for(i = 0; i < 5;i++)
{
int j = 0;
for(j = 0;j<4-i;j++)
{
printf(" ");
}
for(j=0;j<=i;j++)
{
printf("%c ",ch);
}
printf("\n");
}
return 0;
}
题解13 | #ASCII码#
链接:https://www.nowcoder.com/practice/4280d330fe314e8f98cd5c593e3e9190
#include <stdio.h>
int main()
{
char arr[]={73, 32, 99, 97, 110, 32, 100, 111, 32, 105, 116 , 33};
int i = 0;
int sz = sizeof(arr)/sizeof(arr[0]);
for(i = 0; i <sz;i++)
{
printf("%c",arr[i]);
}
return 0;
}
题解14 | # 出生日期输入输出
链接:https://www.nowcoder.com/practice/4a4a9dd1edb6453ba4a0432319200743
#include <stdio.h>
int main() {
int year = 0;
int month = 0;
int date = 0;
scanf("%4d%2d%2d", &year, &month, &date);
printf("year=%04d\n", year);
printf("month=%02d\n", month);
printf("date=%02d\n", date);
return 0;
}
题解15 | # 按照格式输入并交换输出
链接:https://www.nowcoder.com/practice/95eb723a3e854376a7eb6d116cc7d875
#include <stdio.h>
int main() {
int a = 0;
int b = 0;
scanf("a=%d,b=%d",&a,&b);
int tmp = 0;
tmp = a;
a = b;
b = tmp;
printf("a=%d,b=%d",a,b);
return 0;
}
题解16 | # 字符转ASCII码
链接:https://www.nowcoder.com/practice/93f4d05a02d9468db424ed4316bfc8fd
#include <stdio.h>
int main()
{
char ch = '\0';
ch = getchar();
printf("%d\n",ch);
return 0;
}
题解17 | # 计算表达式的值
链接:https://www.nowcoder.com/practice/58457d27f91043edaf95b6591bb64fd6
#include <stdio.h>
int main()
{
int a = 40;
int c = 212;
printf("%d\n",(-8+22)*a-10+c/2);
return 0;
}
题解18 | # 计算带余除法
链接:https://www.nowcoder.com/practice/34d3911bf2fd48a285f6396e886a1259
#include <stdio.h>
int main()
{
int a = 0;
int b = 0;
scanf("%d %d",&a,&b);
printf("%d %d\n",a/b,a%b);
return 0;
}
题解19 | # 反向输出一个四位数
链接:https://www.nowcoder.com/practice/1f7c1d67446e4361bf4af67c08e0b8b0
#include <stdio.h>
int main()
{
int n = 0;
scanf("%d",&n);
while(n)
{
printf("%d",n%10);
n = n /10;
}
return 0;
}
题解20 | # kiki算数
链接:https://www.nowcoder.com/practice/bcaf710fb58a44e1b678a890e6e90d7c
#include <stdio.h>
int main()
{
int a = 0;
int b = 0;
scanf("%d %d",&a,&b);
int sum = ((a%100)+(b%100))%100;
printf("%d\n",sum);
return 0;
}
#include <stdio.h>
int main()
{
int a = 0;
int b = 0;
scanf("%d %d",&a,&b);
int sum = (a+b)%100;
printf("%d\n",sum);
return 0;
}
题解21 | # 浮点数的个位数字
链接:https://www.nowcoder.com/practice/ffa94d27c6534396aef38813535c279f
#include <stdio.h>
int main()
{
double d = 0.0;
scanf("%lf",&d);
int n = (int)d;
printf("%d\n",n%10);
return 0;
}
#include <stdio.h>
int main()
{
int n = 0;
scanf("%d", &n);
printf("%d\n", n % 10);
return 0;
}
题解22 | # 你能活多少秒
链接:https://www.nowcoder.com/practice/e1d1bd99fee34b66ae3c777b74d555c8
#include <stdio.h>
int main()
{
int age = 0;
scanf("%d", &age);
long seconds = age * 3.156e7;
printf("%ld\n", seconds);
return 0;
}
题解23 | # 时间转换
链接:https://www.nowcoder.com/practice/c4ae7bcac7f9491b8be82ee516a94899
#include <stdio.h>
int main()
{
int seconds = 0;
scanf("%d", &seconds);
int h = seconds /3600;
int min = (seconds%3600)/60;
int s = (seconds%3600)%60;
printf("%d %d %d\n", h,min,s);
return 0;
}
题解24 | # 总成绩和平均分计算
链接:https://www.nowcoder.com/practice/0fa5132c156b434da4347ad051c4be22
#include <stdio.h>
int main()
{
double score[3]={0.0} ;
int i = 0;
double sum = 0.0;
for(i = 0;i<3;i++)
{
scanf("%lf",&score[i]);
sum += score[i];
}
printf("%.2lf %.2lf",sum,sum/3.0);
return 0;
}
#include <stdio.h>
int main()
{
double score[3] = { 0.0 };
scanf("%lf %lf %lf", &score[0], &score[1], &score[2]);
double sum = score[0] + score[1] + score[2];
double avg = sum / 3.0;
printf("%.2lf %.2lf", sum, avg);
return 0;
}
#include <stdio.h>
int main()
{
double score = 0.0 ;
int i = 0;
double sum = 0.0;
for (i = 0; i < 3; i++)
{
scanf("%lf", &score);
sum += score;
}
printf("%.2lf %.2lf", sum, sum / 3.0);
return 0;
}
题解25 | # 计算体重指数
链接:https://www.nowcoder.com/practice/422f6341cf1b4212a7f8c703df111389
#include <stdio.h>
int main()
{
int weight = 0;
int high = 0;
double BMI = 0.0;
scanf("%d %d",&weight,&high);
BMI = (weight/((high/100.0)*((high/100.0))));
printf("%.2f",BMI);
return 0;
}
题解26 | # 计算三角形的周长和面积
链接:https://www.nowcoder.com/practice/109a44d649a142d483314e8a57e2c710
#include <stdio.h>
#include <math.h>
int main()
{
double a = 0.0;
double b = 0.0;
double c = 0.0;
double circumference = 0.0;
double area = 0.0;
scanf("%lf %lf %lf", &a, &b, &c);
circumference = a + b + c;
double p = circumference / 2;
area = sqrt(p*(p - a)*(p - b)*(p - c));
printf("circumference=%.2lf area=%.2lf\n", circumference, area);
return 0;
}
题解27 | # 计算球体的体积
链接:https://www.nowcoder.com/practice/0f5d9bfcd63b47fda2052a583b1fbd1f
#include <stdio.h>
int main()
{
double r = 0.0;
scanf("%lf",&r);
double π = 3.1415926;
double v = 4.0/3*π*r*r*r;
printf("%.3f",v);
return 0;
}
题解28 | # 大小写转换
链接:https://www.nowcoder.com/practice/4e089ee8966a4ed4b306f64e68d45264
#include <stdio.h>
int main()
{
char ch = '\0';
while (scanf("%c", &ch) != EOF)
{
if (ch >= 'a' && ch <= 'z')
{
printf("%c\n", ch - 32);
}
if (ch >= 'A' && ch <= 'Z')
{
printf("%c\n", ch + 32);
}
}
return 0;
}
题解29 | # 2的n次方计算
链接:https://www.nowcoder.com/practice/35a1e8b18658411388bc1672439de1d9
#include <stdio.h>
int main()
{
int n = 0;
scanf("%d",&n);
printf("%d\n",1<<n);
return 0;
}
题解30 | # KIKI喝酸奶
链接:https://www.nowcoder.com/practice/c7721f3a1b1a47a783974453e82cadbb
#include <stdio.h>
int main()
{
int n = 0;
int h = 0;
int m = 0;
while (scanf("%d %d %d", &n, &h, &m) != EOF)
{
if (m % h == 0)
{
printf("%d\n", n - (m / h));
}
else
{
printf("%d\n", n - (m / h) - 1);
}
}
return 0;
}
#include <stdio.h>
int main()
{
int h = 0;
int m = 0;
int n = 0;
while (scanf("%d %d %d", &n, &h, &m) != EOF)
{
if (m % h )
{
printf("%d\n", n - (m / h) - 1);
}
else
{
printf("%d\n", n - (m / h) );
}
}
return 0;
}
题解31 | # 发布信息
链接:https://www.nowcoder.com/practice/20e59d0f388448c68f581b9d3ca66049
#include <stdio.h>
int main()
{
printf("I lost my cellphone!");
return 0;
}
题解32 | # 输出学生信息
链接:https://www.nowcoder.com/practice/8e94458049eb4e838f711bbd1be0045e
#include <stdio.h>
int main()
{
printf("Name Age Gender\n");
printf("---------------------\n");
printf("Jack 18 man\n");
return 0;
}
题解33 | #计算平均成绩
链接:https://www.nowcoder.com/practice/30a28eb88c3f4e87be1a5b397ddd6fe2
#include <stdio.h>
int main()
{
int score[5]={0};
int i = 0;
int sum = 0;
for(i=0;i<5;i++)
{
scanf("%d",&score[i]);
sum += score[i];
}
printf("%.1lf\n",sum/5.0);
return 0;
}
#include <stdio.h>
int main()
{
int num[5] = { 0 };
int i = 0;
for (i = 0; i < 5; i++)
{
scanf("%d", &num[i]);
}
int sum = 0;
for (i = 0; i < 5; i++)
{
sum += num[i];
}
printf("%.1lf\n", sum / 5.0);
return 0;
}
#include <stdio.h>
int main()
{
int i = 0;
int sum = 0;
int num = 0;
for (i = 0; i < 5; i++)
{
scanf("%d", &num);
sum += num;
}
printf("%.1lf\n", sum / 5.0);
return 0;
}
题解34 | # 进制A+B
链接:https://www.nowcoder.com/practice/6187581174ac48278ca3bccf8d534897
#include <stdio.h>
int main()
{
int a = 0;
int b = 0;
scanf("%x %o", &a, &b);
int sum = a + b;
printf("%d\n", sum);
return 0;
}
题解35 | # 判断字母
链接:https://www.nowcoder.com/practice/44d2d63103664913bc243d3836b4f341
#include <stdio.h>
int main()
{
char ch = '\0';
ch = getchar();
if(isalpha(ch))
{
printf("YES");
}
else
{
printf("NO");
}
return 0;
}
题解36 | # 健康评估
链接:https://www.nowcoder.com/practice/08b28e61ff6345febf09969b3a167f7e
#include <stdio.h>
int main()
{
char ch = '\0';
ch = getchar();
if (isalpha(ch))
{
printf("YES");
}
else
{
printf("NO");
}
return 0;
}
题解37 | # 网购
链接:https://www.nowcoder.com/practice/5d7dfd405e5f4e4fbfdff6862c46b751
#include <stdio.h>
int main()
{
double price = 0.0;
int month = 0;
int day = 0;
int coupon = 0;
double last = 0.0;
scanf("%lf %d %d %d", &price, &month, &day, &coupon);
if (month == 11 && day == 11)
{
if (coupon == 1)
{
last = price * 0.7 - 50;
}
else
{
last = price * 0.7;
}
}
else if (month == 12 && day == 12)
{
if (coupon == 1)
{
last = price * 0.8 - 50;
}
else
{
last = price * 0.8;
}
}
if (last < 0.0)
{
printf("%.2lf\n", 0.0);
}
else
{
printf("%.2lf\n", last);
}
return 0;
}
#include <stdio.h>
int main()
{
double price = 0.0;
int month = 0;
int day = 0;
int coupon = 0;
double cut = 0.0;
double last = 0.0;
scanf("%lf %d %d %d", &price, &month, &day, &coupon);
if (month == 11 && day == 11)
{
cut = 0.7;
if (coupon == 1)
{
last = price * cut - 50;
}
else
{
last = price * cut;
}
}
else if (month == 12 && day == 12)
{
cut = 0.8;
if (coupon == 1)
{
last = price * cut - 50;
}
else
{
last = price * cut;
}
}
if (last < 0.0)
{
printf("%.2lf\n", 0.0);
}
else
{
printf("%.2lf\n", last);
}
return 0;
}
#include <stdio.h>
int main()
{
double price = 0.0;
int month = 0;
int day = 0;
int coupon = 0;
scanf("%lf %d %d %d", &price, &month, &day, &coupon);
if (month == 11 && day == 11)
{
price *= 0.7;
if (coupon == 1)
{
price -= 50;
}
}
else if (month == 12 && day == 12)
{
price *= 0.8;
if (coupon == 1)
{
price -= 50;
}
}
if (price < 0.0)
{
printf("%.2lf\n", 0.0);
}
else
{
printf("%.2lf\n", price);
}
return 0;
}
#include <stdio.h>
int main()
{
double price = 0.0;
int month = 0;
double cut = 0.0;
int flag = 0;
int day = 0;
double last = 0.0;
scanf("%lf %d %d %d", &price, &month, &day, &flag);
if (month == 11 && day == 11)
{
cut = 0.7;
}
else if (month == 12 && day == 12)
{
cut = 0.8;
}
last = price * cut - flag * 50;
if (last < 0.0)
{
printf("%.2lf\n", 0.0);
}
else
{
printf("%.2lf\n", last);
}
return 0;
}
题解38 | # 变种水仙花数
链接:https://www.nowcoder.com/practice/c178e3f5cc4641dfbc8b020ae79e2b71
#include <stdio.h>
int main()
{
int i = 0;
for(i = 10000;i<=99999;i++)
{
int j = 0;
int sum = 0;
for(j=10;j<=10000;j*=10)
{
sum += (i/j)*(i%j);
}
if(sum == i)
{
printf("%d ",i);
}
}
return 0;
}
题解39 | # 争夺前五名
链接:https://www.nowcoder.com/practice/cd052308a1c44a88ad00255f312c3e14
#include <stdio.h>
int main()
{
int n = 0;
int arr[40] = {0};
scanf("%d", &n);
int i = 0;
for (i = 0; i < 40; i++)
{
scanf("%d", &arr[i]);
}
for (i = 0; i < n - 1; i++)
{
int j = 0;
for (j=0;j<n-1-i;j++)
{
if (arr[j]>arr[j+1])
{
int tmp = arr[j];
arr[j]=arr[j+1];
arr[j+1]=tmp;
}
}
}
for (i=n-1;i>=n-5;i--)
{
printf("%d ",arr[i]);
}
printf("\n");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int cmp_int(const void* e1, const void* e2)
{
return *(int*)e1 - *(int*)e2;
}
int main()
{
int n = 0;
int arr[40] = { 0 };
scanf("%d", &n);
int i = 0;
for (i = 0; i < 40; i++)
{
scanf("%d", &arr[i]);
}
qsort(arr, n, 4, cmp_int);
for (i = n - 1; i >= n - 5; i--)
{
printf("%d ", arr[i]);
}
printf("\n");
return 0;
}
题解40 | # 竞选社长
链接:https://www.nowcoder.com/practice/45a30e3ef51040ed8a7674984d6d1553
#include <stdio.h>
int main()
{
char buf[100] = { 0 };
gets(buf);
int count_a = 0;
int count_b = 0;
int i = 0;
while (buf[i] != '0')
{
if (buf[i] == 'A')
{
count_a++;
}
if (buf[i] == 'B')
{
count_b++;
}
i++;
}
if (count_a > count_b)
{
printf("A\n");
}
else if (count_a < count_b)
{
printf("B\n");
}
else
{
printf("E\n");
}
return 0;
}
#include <stdio.h>
int main()
{
char buf[100] = { 0 };
gets(buf);
int flag = 0;
int i = 0;
while (buf[i] != '0')
{
if (buf[i] == 'A')
{
flag++;
}
if (buf[i] == 'B')
{
flag--;
}
i++;
}
if (flag > 0)
{
printf("A\n");
}
else if (flag < 0)
{
printf("B\n");
}
else
{
printf("E\n");
}
return 0;
}
#include <stdio.h>
int main()
{
int ch = 0;
int flag = 0;
while(((ch = getchar())!='0')&& ch !=EOF)
{
if(ch == 'A')
{
flag++;
}
if(ch == 'B')
{
flag--;
}
}
if(flag>0)
{
printf("A\n");
}
else if(flag<0)
{
printf("B\n");
}
else
{
printf("E\n");
}
return 0;
}
题解41 | # 你是天才吗?
链接:https://www.nowcoder.com/practice/557cc54704bb4d56b73b62d1a5455331
#include <stdio.h>
int main()
{
int IQ = 0;
while (~scanf("%d", &IQ))
{
if (IQ >= 140)
{
printf("Genius\n");
}
}
return 0;
}
#include <stdio.h>
int main()
{
int IQ = 0;
while (scanf("%d", &IQ) != EOF)
{
if (IQ >= 140)
{
printf("Genius\n");
}
}
return 0;
}
题解42 | # 完美成绩
链接:https://www.nowcoder.com/practice/8312e497509a450f968d9a6a2381ce32
#include <stdio.h>
int main()
{
int score = 0;
while(scanf("%d",&score)!=EOF)
{
if(score>=90&&score<=100)
{
printf("Perfect\n");
}
}
return 0;
}
#include <stdio.h>
int main()
{
int score = 0;
while(~scanf("%d",&score)
{
if(score>=90&&score<=100)
{
printf("Perfect\n");
}
}
return 0;
}
题解43 | # 及格分数
链接:https://www.nowcoder.com/practice/56513524333148b38945e1989bc7df4e
#include <stdio.h>
int main()
{
int score = 0;
while (scanf("%d", &score) != EOF)
{
if(score>=60&&score<=100)
{
printf("Pass\n");
}
else
{
printf("Fail\n");
}
}
return 0;
}
#include <stdio.h>
int main()
{
int score = 0;
while (~scanf("%d", &score))
{
if (score >= 60 && score <= 100)
{
printf("Pass\n");
}
else
{
printf("Fail\n");
}
}
return 0;
}
题解44 | # 判断整数奇偶性
链接:https://www.nowcoder.com/practice/a8b018667e274af29b5f76a6673450fc
#include <stdio.h>
int main()
{
int n = 0;
while (scanf("%d", &n) != EOF)
{
if(n%2==0)
{
printf("Even\n");
}
else
{
printf("Odd\n");
}
}
return 0;
}
#include <stdio.h>
int main()
{
int num = 0;
while (~scanf("%d", &num))
{
if (num % 2 == 0)
{
printf("Even\n");
}
else
{
printf("Odd\n");
}
}
return 0;
}
题解45 | # 最高分数
链接:https://www.nowcoder.com/practice/52c18a3b49a54fc98107fbdde1415f90
#include <stdio.h>
int main()
{
int n1= 0;
int n2=0;
int n3=0;
while(~scanf("%d %d %d",&n1,&n2,&n3))
{
if(n1<n2)
{
int tmp = n1;
n1=n2;
n2=tmp;
}
if(n1<n3)
{
int tmp = n1;
n1=n3;
n3=tmp;
}
printf("%d\n",n1);
}
return 0;
}
#include <stdio.h>
int main()
{
int n1 = 0;
int n2 = 0;
int n3 = 0;
while (~scanf("%d %d %d", &n1,&n2,&n3))
{
int max = n1>n2?n1:n2;
max = max>n3?max:n3;
printf("%d\n",max);
}
return 0;
}
#include <stdio.h>
int main()
{
int score[3]={0};
while(~scanf("%d %d %d",&score[0],&score[1],&score[2]))
{
int max = 0;
int i = 0;
for(i=0;i<3;i++)
{
if(max<score[i])
{
max = score[i];
}
}
printf("%d\n",max);
}
return 0;
}
#include <stdio.h>
int main()
{
int score[3] = { 0 };
while (~scanf("%d %d %d", &score[0], &score[1], &score[2]))
{
int max = score[0];
int i = 0;
for (i = 1; i < 3; i++)
{
if (max < score[i])
{
max = score[i];
}
}
printf("%d\n", max);
}
return 0;
}
题解46 | # 判断是元音还是辅音
链接:https://www.nowcoder.com/practice/7eb4df4d52c44d309081509cf52ecbc4
#include <stdio.h>
int main()
{
int ch = 0;
char vowel[] = "AaEeIiOoUu";
while ((ch = getchar()) != EOF)
{
int i = 0;
for (i = 0; i < 10; i++)
{
if (ch == vowel[i])
{
printf("Vowel\n");
break;
}
}
if (i == 10)
{
printf("Consonant\n");
}
getchar();
}
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
int ch = 0;
char vowel[] = "AaEeIiOoUu";
while ((ch = getchar()) != EOF)
{
if (strchr(vowel, ch))
{
printf("Vowel\n");
}
else
{
printf("Consonant\n");
}
getchar();
}
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
int ch = 0;
char vowel[] = "AaEeIiOoUu";
while (scanf("%c",&ch) != EOF)
{
if (strchr(vowel, ch))
{
printf("Vowel\n");
}
else
{
printf("Consonant\n");
}
getchar();
}
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
int ch = 0;
char vowel[] = "AaEeIiOoUu";
while (scanf(" %c", &ch) != EOF)
{
if (strchr(vowel, ch))
{
printf("Vowel\n");
}
else
{
printf("Consonant\n");
}
}
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
int ch = 0;
char vowel[] = "AaEeIiOoUu";
while (scanf("%c\n", &ch) != EOF)
{
if (strchr(vowel, ch))
{
printf("Vowel\n");
}
else
{
printf("Consonant\n");
}
}
return 0;
}
题解47 | # 判断是不是字母
链接:https://www.nowcoder.com/practice/91a588dd4cd244bfa616f17603ec123c
#include <stdio.h>
int main()
{
int ch = 0;
while(scanf("%c\n",&ch)!=EOF)
{
if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
{
printf("%c is an alphabet.\n",ch);
}
else
{
printf("%c is not an alphabet.\n",ch);
}
}
return 0;
}
#include <stdio.h>
#include <ctype.h>
int main()
{
int ch = 0;
while (scanf("%c\n", &ch) != EOF)
{
if (isalpha(ch))
{
printf("%c is an alphabet.\n", ch);
}
else
{
printf("%c is not an alphabet.\n", ch);
}
}
return 0;
}
题解48 | # 字母大小写转换
链接:https://www.nowcoder.com/practice/850ebd30a2a34cfc87199da3fc15786a
#include <stdio.h>
int main()
{
int ch = 0;
while (scanf("%c\n", &ch) != EOF)
{
if(ch>='a'&&ch<='z')
{
printf("%c\n", ch-32);
}
if(ch>='A'&&ch<='Z')
{
printf("%c\n", ch+32);
}
}
return 0;
}
#include <stdio.h>
int main()
{
int ch = 0;
while (~scanf("%c\n", &ch))
{
if(ch>='a'&&ch<='z')
{
printf("%c\n", ch-32);
}
if(ch>='A'&&ch<='Z')
{
printf("%c\n", ch+32);
}
}
return 0;
}
#include <stdio.h>
#include <ctype.h>
int main()
{
int ch = 0;
while (~scanf("%c\n", &ch))
{
if(isupper(ch))
{
printf("%c\n", ch+32);
}
if(islower(ch))
{
printf("%c\n", ch-32);
}
}
return 0;
}
#include <stdio.h>
#include <ctype.h>
int main()
{
int ch = 0;
while ((ch = getchar()) != EOF)
{
if (islower(ch))
{
printf("%c\n", toupper(ch));
}
else
{
printf("%c\n", tolower(ch));
}
getchar();
}
return 0;
}
#include <stdio.h>
#include <ctype.h>
int main()
{
int ch = 0;
while (~scanf("%c\n", &ch))
{
if (isupper(ch))
{
printf("%c\n", tolower(ch));
}
else if(islower(ch))
{
printf("%c\n", toupper(ch));
}
}
return 0;
}
题解49 | # 判断两个数的大小关系
#include <stdio.h>
int main()
{
int num1 = 0;
int num2 = 0;
while (scanf("%d %d", &num1, &num2) != EOF)
{
if (num1 > num2)
{
printf("%d>%d\n", num1, num2);
}
else if (num1 < num2)
{
printf("%d<%d\n", num1, num2);
}
else
{
printf("%d=%d\n", num1, num2);
}
}
return 0;
}
题解50 | # 计算单位阶跃函数
链接:https://www.nowcoder.com/practice/0b23793ae48a4e6cb7dfff042c959a04
#include <stdio.h>
int main()
{
int t = 0;
while(scanf("%d",&t)!=EOF)
{
if(t>0)
{
printf("1\n");
}
else if (t<0)
{
printf("0\n");
}
else
{
printf("0.5\n");
}
}
return 0;
}
#include <stdio.h>
int main()
{
int t = 0;
while(scanf("%d",&t)!=EOF)
{
if(t>0)
{
printf("%d\n",1);
}
else if (t<0)
{
printf("%d\n",0);
}
else
{
printf("%.1f\n",0.5);
}
}
return 0;
}
题解51| # 三角形判断
链接:https://www.nowcoder.com/practice/689ec1e742394e09b1059556fc167b65
#include <stdio.h>
int main()
{
int a = 0;
int b = 0;
int c = 0;
while(~scanf("%d %d %d",&a,&b,&c))
{
if((a+b>c)&&(a+c>b)&&(b+c>a))
{
if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&b!=a))
{
printf("Isosceles triangle!\n");
}
else if (a==b&&b==c)
{
printf("Equilateral triangle!\n");
}
else
{
printf("Ordinary triangle!\n");
}
}
else
{
printf("Not a triangle!\n");
}
}
return 0;
}
题解52| # 衡量人体胖瘦程度
链接:https://www.nowcoder.com/practice/4d604603fae94a26b59b7bc18f363bc0
#include <stdio.h>
int main()
{
int weight = 0;
int hight = 0;
while (scanf("%d %d", &weight, &hight) != EOF)
{
double BMI = weight / ((hight / 100.0) * (hight / 100.0));
if (BMI < 18.5)
{
printf("Underweight\n");
}
else if (BMI >= 18.5 && BMI <= 23.8)
{
printf("Normal\n");
}
else if (BMI > 23.9 && BMI <= 27.9)
{
printf("Overweight\n");
}
else
{
printf("Obese\n");
}
}
return 0;
}
题解53| # 计算一元二次方程
链接:https://www.nowcoder.com/practice/7da524bb452441b2af7e64545c38dc26
#include <stdio.h>
#include <math.h>
int main()
{
double a = 0.0;
double b = 0.0;
double c = 0.0;
while (scanf("%lf %lf %lf", &a, &b, &c) != EOF)
{
if (a == 0)
{
printf("Not quadratic equation\n");
}
else
{
double disc = b * b - 4 * a * c;
if (disc == 0)
{
if (b == 0 && c == 0)
{
printf("x1=x2=0.00\n");
}
else
printf("x1=x2=%.2f\n", (-b) / (2 * a));
}
else if (disc > 0)
{
printf("x1=%.2lf;x2=%.2lf\n", (-b - sqrt(disc)) / (2 * a), (-b + sqrt(disc)) / (2 * a));
}
else
{
double real = (-b) / (2 * a);
double image = sqrt(-disc) / (2 * a);
printf("x1=%.2lf-%.2lfi;x2=%.2lf+%.2lfi\n", real, image, real, image);
}
}
}
return 0;
}
题解54| # 获得月份天数
链接:https://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6
#include <stdio.h>
int main()
{
int year = 0;
int month = 0;
int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
while(~scanf("%d %d",&year,&month))
{
int day = days[month-1];
if((year%4==0&&year%100!=0)||(year%400==0))
{
if(month==2)
{
day+=1;
}
}
printf("%d\n",day);
}
return 0;
}
题解55| # 简单计算器
链接:https://www.nowcoder.com/practice/b8f770674ba7468bb0a0efcc2aa3a239
#include <stdio.h>
int main()
{
double n1 = 0;
double n2 = 0;
char op = 0;
scanf("%lf %c %lf",&n1,&op,&n2);
switch(op)
{
case '+':
printf("%.4lf+%.4lf=%.4lf\n",n1,n2,n1+n2);
break;
case '-':
printf("%.4lf-%.4lf=%.4lf\n",n1,n2,n1-n2);
break;
case '*':
printf("%.4lf*%.4lf=%.4lf\n",n1,n2,n1*n2);
break;
case '/':
if(n2==0.0)
{
printf("Wrong!Division by zero!\n");
}
else
{
printf("%.4lf/%.4lf=%.4lf\n",n1,n2,n1/n2);
}
break;
default:
printf("Invalid operation!\n");
break;
}
return 0;
}
题解56| # 线段图案
#include <stdio.h>
int main()
{
int n = 0;
while(scanf("%d",&n)!=EOF)
{
int i = 0;
for(i=0;i<n;i++)
{
printf("*");
}
printf("\n");
}
return 0;
}
题解57| # 正方形图案
#include <stdio.h>
int main()
{
int n = 0;
while(scanf("%d",&n)!=EOF)
{
int i = 0;
for(i=0;i<n;i++)
{
int j = 0;
for(j = 0;j<n;j++)
{
printf("* ");
}
printf("\n");
}
}
return 0;
}
题解58| # 直角三角形图案
#include <stdio.h>
int main()
{
int n = 0;
while (scanf("%d", &n)!=EOF)
{
int i = 0;
for (i = 1; i <= n; i++)
{
int j = 0;
for (j = 1; j <= i; j++)
{
printf("* ");
}
printf("\n");
}
}
return 0;
}
题解59| # 翻转直角三角形图案
#include <stdio.h>
int main()
{
int n = 0;
while(scanf("%d",&n)!=EOF)
{
int i = 0;
for(i = 0;i<n;i++)
{
int j = 0;
for(j = 0;j<n-i;j++)
{
printf("* ");
}
printf("\n");
}
}
return 0;
}
题解60| # 带空格直角三角形图案
#include <stdio.h>
int main()
{
int n = 0;
while (~scanf("%d", &n))
{
int i = 0;
for (i = 0; i < n; i++)
{
int j = 0;
for (j = 0; j < n - 1 - i; j++)
{
printf(" ");
}
for (j = 0; j <= i; j++)
{
printf("* ");
}
printf("\n");
}
}
return 0;
}
#include <stdio.h>
int main()
{
int n = 0;
while(~scanf("%d",&n))
{
int i = 0;
for(i = 1;i<=n;i++)
{
int j = 0;
for(j = 1;j<=n-i;j++)
{
printf(" ");
}
for(j = 1;j<=i;j++)
{
printf("* ");
}
printf("\n");
}
}
return 0;
}
#include <stdio.h>
int main()
{
int n = 0;
while (~scanf("%d", &n))
{
int i = 0;
for (i = 0; i < n; i++)
{
int j = 0;
for (j = 0; j < n - 1 - i; j++)
{
if (i + j < m - n - 1)
{
printf(" ");
}
else
{
printf("* ");
}
printf("\n");
}
}
return 0;
}