当前位置:网站首页>C language: the sorting problem of circle number reporting
C language: the sorting problem of circle number reporting
2022-07-04 12:39:00 【Nianchi ichthyology programming】
problem :
from n A circle of individuals , Sequence number . Count from the first person ( from 1 To 3 Number off ), Usually arrive 3 Of the people out of the circle , Ask the last one who left the original number .
Code
#include <stdio.h>
int main()
{
int num[50],n,*p,j,loop,i,m,k;
printf(" Please enter the number of people in this circle :");
scanf("%d",&n);
p = num;
for(j = 0 ; j < n ; j++){
*(p+j) = j+1;
}
i = 0;
m = 0;
k = 0;
while(m<n-1){
if(*(p+i)!=0){
k++;
}
if(k==3){
k = 0;
*(p+i)=0;
m++;
}
i++;
if(i==n){
i = 0;
}
}
printf(" Now the rest are :");
for(loop=0;loop<n;loop++){
if(num[loop]!=0){
printf("%2d Number \n",num[loop]);
}
}
return 0;
}
边栏推荐
- Global and Chinese markets of NOx analyzers 2022-2028: Research Report on technology, participants, trends, market size and share
- Interview question MySQL transaction (TCL) isolation (four characteristics)
- 轻松玩转三子棋
- ASP. Net razor – introduction to VB loops and arrays
- DDS-YYDS
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
- How to use "bottom logic" to see the cards in the world?
- MySQL performance optimization index
- Googgle guava ImmutableCollections
- Kivy教程之 08 倒计时App实现timer调用(教程含源码)
猜你喜欢

Leetcode day 17
![Cadence physical library lef file syntax learning [continuous update]](/img/d5/0671935b074e538a2147dbe51a5a70.jpg)
Cadence physical library lef file syntax learning [continuous update]

Hongke case study on storm impact in coastal areas of North Carolina using lidar
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9](/img/ed/0edff23fbd3880bc6c9dabd31755ac.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9

0x15 string
![[data clustering] section 3 of Chapter 4: DBSCAN performance analysis, advantages and disadvantages, and parameter selection methods](/img/e6/2b46d72049ea50f89d0234eab88439.png)
[data clustering] section 3 of Chapter 4: DBSCAN performance analysis, advantages and disadvantages, and parameter selection methods

I want to talk about yesterday

R language -- readr package reads and writes data

When synchronized encounters this thing, there is a big hole, pay attention!
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13](/img/29/49da279efed22706545929157788f0.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
随机推荐
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22
17.内存分区与分页
《天天数学》连载57:二月二十六日
[Yu Yue education] 233 pre school children's language education reference questions in the spring of 2019 of the National Open University
16.内存使用与分段
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 18
Globalsign's SSL certificate products
First knowledge of spark - 7000 words +15 diagrams, and learn the basic knowledge of spark
8.8.1-PointersOnC-20220214
Flet教程之 按钮控件 ElevatedButton入门(教程含源码)
Map container
C语言:围圈报号排序问题
Leetcode: 408 sliding window median
The database connection code determines whether the account password is correct, but the correct account password always jumps to the failure page with wrong account password
Memory computing integration: AI chip architecture in the post Moorish Era
Uva536 binary tree reconstruction tree recovery
R语言--readr包读写数据
Bottom Logic -- Mind Map
Hongke case study on storm impact in coastal areas of North Carolina using lidar
[the way of programmer training] - 2 Perfect number calculation