(1)#include <stdio.h>
int main()
{
int n,m,i;
double p[2023];
scanf("%d %d",&n,&m);
for(i=0; i<n; i++)
{
scanf("%lf\",&p[i]);
if(p[i]<m*1.0)
{
printf("On Sale! %.1lf",p[i]);
printf("\n");
}
}
return 0;
}
(2)
#include <stdio.h>
#include <stdbool.h>
// 计算身份证号码的校验码
char calculate_check_code(char id[17]) {
int weights[17] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
char check_codes[11] = "10X98765432";
int sum = 0;
for (int i = 0; i < 17; i++) {
sum += (id[i] - '0') * weights[i];
}
return check_codes[sum % 11];
}
// 验证身份证号码的有效性
bool validate_id(char id[18]) {
for (int i = 0; i < 17; i++) {
if (id[i] < '0' || id[i] > '9') {
return false;
}
}
char check_code = calculate_check_code(id);
return check_code == id[17];
}
int main() {
int n;
scanf("%d", &n);
char id[18];
bool has_error = false;
for (int i = 0; i < n; i++) {
scanf("%s", id);
if (!validate_id(id)) {
printf("%s\n", id);
has_error = true;
}
}
if (!has_error) {
printf("All passed\n");
}
return 0;
}
(3)
#include <stdio.h>
int main()
{
int fen5,fen2,fen1,total,count,x,i,j,k;
count=0;
scanf("%d",&x);
if(x>8 && x<100){
for(i=x/5;i>=1;i--){
for(j=x/2;j>=1;j--){
for(k=x;k>=1;k--){
if((5*i+j*2+k)==x){
count++;
total=i+j+k;
printf("fen5:%d, fen2:%d, fen1:%d, total:%d\n",i,j,k,total);
}
}
}}
printf("count = %d",count);
}
return 0;
}