当前位置:网站首页>C language classic exercises
C language classic exercises
2022-07-24 04:22:00 【Serendipity_-】
Input a character from the terminal and output , Until I met ’q’ end :
// Input a character from the terminal and output , Until I met 'q' end
#include <stdio.h>
int main(int argc, char const *argv[])
{
char i;
while (1)
{
scanf("%c", &i);
if (i == '\n')
continue;
if (i == 'q')
break;
printf("%c\n", i);
}
return 0;
}
Loop in a 5 digit , Judge whether it is palindrome number . When the input 0 When the cycle ends .
such as 12321 It's palindrome number , One digit is the same as ten thousand , Ten is the same as one thousand .
// Loop in a 5 digit , Judge whether it is palindrome number . When the input 0 When the cycle ends .
// namely 12321 It's palindrome number , One digit is the same as ten thousand , Ten is the same as one thousand .
#include <stdio.h>
int main(int argc, char const *argv[])
{
int num;
while (1)
{
scanf("%d", &num);
if (num > 9999 && num < 100000)
{
int g = num % 10;
int s = num / 10 % 10;
int q = num / 1000 % 10;
int w = num / 10000;
if (g == w && s == q)
printf("%d It's palindrome number \n", num);
else
printf("%d Not palindrome \n", num);
}
else if (0 == num)
{
break;
}
else
{
printf(" Please enter the correct number !\n");
}
}
return 0;
}
Calculate the size of the array :
#include <stdio.h>
int main(int argc, char const *argv[])
{
int a[5] = {
0};
printf("%d", sizeof(a));
return 0;
}
Before calculating the Fibonacci sequence 15 Items are output in reverse order
1 1 2 3 5 8 13 21 …
From 3 A start , The first two terms add up to the third term
// Before calculating the Fibonacci sequence 15 Items are output in reverse order
// 1 1 2 3 5 8 13 21 ...
// From 3 A start , The first two terms add up to the third term
#include <stdio.h>
int main(int argc, char const *argv[])
{
int arr[15] = {
1, 1};
for (int i = 2; i < 15; i++)
{
arr[i] = arr[i - 1] + arr[i - 2];
}
for (int i = 14; i >= 0; i--)
{
printf("%d ", arr[i]);
}
return 0;
}
Enter a string of characters , Calculate the number of spaces
// Enter a string of characters , Calculate the number of spaces
#include <stdio.h>
int main(int argc, char const *argv[])
{
int sum = 0;
char s[100] = "";
scanf("%[^\n]", s);
for (int i = 0; i < 100; i++)
{
if (s[i] == 32)
{
sum++;
}
}
printf("%d", sum);
return 0;
}
边栏推荐
- Exploration of new mode of code free production
- NFT insider 67: Barcelona Football Club launched its first NFT work, and Dubai launched the national metauniverse strategy
- 阿里淘系面试题:Redis 如何实现库存扣减操作和防止被超卖?
- How to protect JDBC applications from SQL injection
- 00cm non, make sure to go online with the business party once in advance, and make everything better
- 直播课堂系统04-创建service模块
- Design and implementation of data analysis platform for intelligent commerce
- Go language series - synergy GMP introduction - with ByteDance interpolation
- Insider of LAN SDN hard core technology 22 Kang long regrets -- Specifications and restrictions (Part 2)
- [hope to answer] the data cannot be synchronized correctly
猜你喜欢

Will your NFT disappear? Dfinity provides the best solution for NFT storage

How does the trend chart of spot silver change?

Live broadcast preview | practice sharing of opengauss' autonomous operation and maintenance platform dbmind

postgresql源码学习(32)—— 检查点④-核心函数CreateCheckPoint

Pat grade a 1041 be unique

【新手向 】手把手开发一个易于扩展的 Tabs 组件

mysql服务1主2从,主主,MHA配置详细步骤

flask框架中页面跳转与重定向

Go language series - synergy GMP introduction - with ByteDance interpolation

D2dengine edible tutorial (3) -- export rendering targets as image files
随机推荐
Codeforces Round #808 (Div. 2) A - D
Traversal of binary tree
Svg image color modification is not fancy
eCB接口,其实质也 MDSemodet
Iqoo 10 series attacks originos original system to enhance mobile phone experience
C主机对IIC从来分别设置每足够的话,可下几位
LAN SDN hard core technology insider 21 Kang long regrets -- Specifications and restrictions (middle)
Pyth deinitialization averages on many machine decision boundaries, starting on the bus
PostgreSQL source code learning (32) -- checkpoint ④ - core function createcheckpoint
C语言基础学习笔记
Educational Codeforces Round 132 A - D
Ambire wallet opens twitter spaces series
mongo从开始到安装以及遇到的问题
Shell syntax (1)
To -.---
Avoid mistakes, common appium related problems and Solutions
可能有点用的冷知识
Game improvement of smart people: Lesson 2 of Chapter 3: number of factors
[translation] announce krius -- accelerate your monitoring and adoption of kubernetes
Insider of LAN SDN hard core technology 22 Kang long regrets -- Specifications and restrictions (Part 2)