标签:nbsp lse pre stdio.h 变量 std include printf class
PTA
7-38 支票面额
1 #include<stdio.h> 2 3 int main() { 4 int n,f,y; 5 int flag = 0; 6 scanf("%d",&n); 7 for(y=0; flag==0 && y<=50; y++) { 8 for(f=0; f<=100; f++) { 9 if(199*y-98*f+n==0) { 10 flag = 1; 11 break; 12 } 13 } 14 } 15 if(y==51 && f==101) printf("No Solution"); 16 else printf("%d.%d",y-1,f); 17 }
穷举法,注意两点:
1、y、f有隐含的判断条件
2、跳出双重循环,需多设置一个变量
标签:nbsp lse pre stdio.h 变量 std include printf class
原文地址:https://www.cnblogs.com/cxc1357/p/10728133.html