Auto commit

This commit is contained in:
smallkun 2025-04-01 16:23:28 +08:00
parent 0fca9c9a65
commit 49499ddb60
2 changed files with 55 additions and 82 deletions

View File

@ -1,48 +1,28 @@
/*----------------------------------------------------------------------- /*---------------------------------------------------------------------
----------------------------------------------------------------------- ---------------------------------------------------------------------
100
100 222 656 899 65 4%10
978
------------------------------------------------------------------------- (使do....while)
---------------------------------------------------------------------
------------------------------------------------------------------------*/ main
Program-End
Program-End
---------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
int sum_of_even(int arr[], int size); #include <stdlib.h>
int main() int main()
{ {
int numbers[5]; int money = 100;
int i; int year = 1;
int even_sum; /**********Program**********/
printf("【请输入五个正整数:】");
for (i = 0; i < 5; i++) /********** End **********/
{ printf("%d 年后账户上的钱会被花完", year);
if (scanf("%d", &numbers[i]) != 1) printf("\n");
{
printf("输入有误,请确保输入了五个整数。\n");
return 1;
}
if (numbers[i] <= 0)
{
printf("输入有误!请确保输入的是正数。\n");
return 1;
}
}
even_sum = sum_of_even(numbers, 5);
printf("【这五个正整数中的偶数之和为:】%d\n", even_sum);
return 0; return 0;
} }
int sum_of_even(int arr[], int size)
{
int sum = 0;
int i;
/**********Program**********/
for(i=0;i<size;i++){
if(arr[i]%2==0){
sum+= arr[i];
}
}
return sum;
/********** End **********/
}

View File

@ -1,43 +1,36 @@
/*----------------------------------------------------------------------- /*---------------------------------------------------------------------
----------------------------------------------------------------------- ---------------------------------------------------------------------
*fun:
* 20 24 4 13 11
* 11 13 4 24 20
:"*******A*BC*DEF*G****" ---------------------------------------------------------------------
:"A*BC*DEF*G****"使C main
Program-End
-------------------------------------------------------------------------
:main , Program-End
fun , ---------------------------------------------------------------------*/
------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
void fun(char *a) void sort(int *, int);
void main()
{ {
int a[5], i;
for (i = 0; i < 5; i++)
{
scanf("%d,", &a[i]);
}
sort(a, 5);
for (i = 0; i < 5; i++)
{
printf("%d ", a[i]);
}
printf("\n");
}
void sort(int *p, int n)
{
int i, j, temp;
/**********Program**********/ /**********Program**********/
char *p,*q;
p=a;
while(*p == '*'){
p++;
}
for(q=p;q > a;q--){
p=q;
while(*p != '\0'){
*(p-1) = *p;
p++;
}
*(p-1) = '\0';
}
/********** End **********/ /********** End **********/
} }
main()
{
char s[81];
printf("【Enter a string:】\n");
gets(s);
fun(s);
printf("【The string after deleted:】\n");
puts(s);
}