当前位置:网站首页>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;
}
边栏推荐
- 17.内存分区与分页
- [Yu Yue education] 233 pre school children's language education reference questions in the spring of 2019 of the National Open University
- 13、 C window form technology and basic controls (3)
- IIS error, unable to start debugging on the webserver
- VBA, JSON interpretation, table structure -json string conversion
- I want to talk about yesterday
- The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
- Global and Chinese market for naval vessel maintenance 2022-2028: Research Report on technology, participants, trends, market size and share
- Awk getting started to proficient series - awk quick start
- Introduction to random and threadlocalrandom analysis
猜你喜欢
Azure solution: how can third-party tools call azure blob storage to store data?
Detailed explanation of NPM installation and caching mechanism
Source code analysis of the implementation mechanism of multisets in guava class library
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
What if the chat record is gone? How to restore wechat chat records on Apple Mobile
轻松玩转三子棋
It's hard to hear C language? Why don't you take a look at this (V) pointer
记一次 Showing Recent Errors Only Command /bin/sh failed with exit code 1 问题
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20
Here, the DDS tutorial you want | first experience of fastdds - source code compilation & Installation & Testing
随机推荐
Flet教程之 02 ElevatedButton高级功能(教程含源码)(教程含源码)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 18
[notes] in depth explanation of assets, resources and assetbundles
How to use "bottom logic" to see the cards in the world?
Detailed explanation of NPM installation and caching mechanism
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
Netgear switch basic configuration command set
《天天数学》连载57:二月二十六日
Entitas learning [iv] other common knowledge points
SAP ui5 date type sap ui. model. type. Analysis of the display format of date
When synchronized encounters this thing, there is a big hole, pay attention!
Translation D29 (with AC code POJ 27:mode of sequence)
Hongke case study on storm impact in coastal areas of North Carolina using lidar
Fly tutorial 02 advanced functions of elevatedbutton (tutorial includes source code) (tutorial includes source code)
LVS load balancing cluster deployment - Dr direct routing mode
Btrace tells you how to debug online without restarting the JVM
Awk getting started to proficient series - awk quick start
Iterm tab switching order
[data clustering] section 3 of Chapter 4: DBSCAN performance analysis, advantages and disadvantages, and parameter selection methods
Snowflake won the 2021 annual database