鱼C论坛

 找回密码
 立即注册
查看: 2113|回复: 6

[已解决]来个大佬打一下!!

[复制链接]
发表于 2021-12-29 17:03:15 | 显示全部楼层
  1 #include <stdio.h>
  2 int main(int argc, char **argv)
  3 {
  4     int input[2048], odd[1024], even[1024];
  5     char ch[10];
  6     int i = 1, j, k = 1, m = 1, n;
  7     while(1)
  8     {
  9         printf("please input number %d, and press Enter\n",i);
10         scanf("%d",&input[i]);
11         ch[1] = getchar();
12         printf("Do you want to continue input: Y/N\n");
13         scanf("%c",&ch[2]);
14         ch[1] = getchar();
15         if(ch[2] == 'y' || ch[2] == 'Y')
16         {
17             printf("ch2 = %c\n",ch[2]);
18             i++;
19             continue;
20         }
21         else
22         {
23             break;
24         }
25     }
26
27     for(j = 1; j <= i; j++)
28     {
29         if(input[j]%2 != 0)
30         {
31             printf("%d is a odd\n",input[j]);
32             odd[k++] = input[j];     //this arrays save odd
33         }
34         else
35         {
36             printf("%d is a even\n",input[j]);
37             even[m++] = input[j];     //this arrays save even
38         }
39     }
40
41     printf("all odd are:\n");
42     for(j = 1; j < k; j++)
43     {
44         printf("%d  ",odd[j]);
45     }
46     printf("\nall even are:\n");
47     for(j = 1; j < m; j++)
48     {
49         printf("%d  ",even[j]);
50     }
51     printf("\n about odd sum and even sequence, please do it by yourself !!!\n");
52
53     return 0;
54 }
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-4 08:16

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表