由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Computation版 - 问个c programming product code的问题
相关主题
请教Origin使用问题Banned from buying iPads... for life
有人做user experience design这行么去纽约使馆办加拿大签证的drop off一定需要本人吗?
Software/Algorithm Engineer Job Opening in Miami, FLcan anyone know what this information from USCIC means after I request service?
转WEB DESIGNER6/1 SR催绿,结果今天收到这个。。。
转载一个起诉USCIS的案子八卦一下新大法官的妈 (转载)
有律师和房屋代理人是同一个人的情况吗该不该接受这个工作?????
问个严重超速上court找人代表我去的问题大家收到mha的邮件了吗?
投票日不要忘了Do Marathons Hurt Your Knees?
相关话题的讨论汇总
话题: banned话题: valid话题: program话题: scanf话题: 问个
进入Computation版参与讨论
1 (共1页)
g******a
发帖数: 13
1
刚开始学c programming,问个浅显的问题。该怎么写这个program? 用getchar() 还是
scanf()?? 哪位能写个
program让我学习一下吗?
Let us say a Company uses codes to represent its various products
a codes includes, among other information, a character in tenth position
that represents the zone from which that product was made, and 4 digits
integer in position 4 thru 7 that represents the district in which it will
be sold. Due to some reorganization, products from zone R are banned
from being sold in districts with a designation of 2000 or higher.
Writ a complete program to count and print number of banned and valid code
entered.
Example: TRV2475A5R-14 valid
TRL2k74A5R-11 : district is not numeric
TRV2105A2 : improper code length
The user should signal end of file to stop the program
L*******g
发帖数: 913
2
两个都可以
#include
...
int i, n, ok, banned, valid;
char c[20];
scanf("%d", &n);
banned=valid=0;
for(i=0; i scanf("%s", c);
if(strlen(c)>=10) {
ok=1;
for(j=3; j<7 && ok; j++) { if(c[j]<'0' || c[j]>'9') ok=0; }
if(ok) {
if(c[9]=='R' && c[3]>='2') banned++;
else valid++;
}
}
}
printf("banned=%d, valid=%d\n", banned, valid);
g******a
发帖数: 13
3
Thanks for your help! I compiled the program you wrote, however it always
returned banned=0, valid=0
L*******g
发帖数: 913
4
我没检查我写的code。你可以在不同的地方加一点输出,debug看看
1 (共1页)
进入Computation版参与讨论
相关主题
Do Marathons Hurt Your Knees?转载一个起诉USCIS的案子
obama也真是stupid有律师和房屋代理人是同一个人的情况吗
这比较搞!TG封禁有关时空穿越题材? (转载)问个严重超速上court找人代表我去的问题
Representative Political System is out of date投票日不要忘了
请教Origin使用问题Banned from buying iPads... for life
有人做user experience design这行么去纽约使馆办加拿大签证的drop off一定需要本人吗?
Software/Algorithm Engineer Job Opening in Miami, FLcan anyone know what this information from USCIC means after I request service?
转WEB DESIGNER6/1 SR催绿,结果今天收到这个。。。
相关话题的讨论汇总
话题: banned话题: valid话题: program话题: scanf话题: 问个