Qualification Round Africa 2010 Problem A. Store Credit
来源:互联网 发布:java实用教程第三版pdf 编辑:程序博客网 时间:2024/06/03 13:54
/*Qualification Round Africa 2010Problem A. Store Credit*/#include<stdio.h>const char FILE_NAME[] = "A-large-practice.in";const char OUT_FILE_NAME[] = "A-large-practice.out";#define NEXTLINEfgets(line,sizeof(line),readfp)#defineHELLOprintf("hello\n")#include<stdlib.h>#include<string.h>void preread_file(){int count_line = 0, i;int line_num;char line[8000];FILE *readfp = fopen(FILE_NAME,"r");if (readfp == NULL){printf("Cannot open %s\n", FILE_NAME);exit(8);}NEXTLINE; ++count_line;line_num = atoi(line);while (NEXTLINE)++count_line;if (line_num*3!=(count_line-1)){printf("line number = %d\tcount line = %d\n",line_num,count_line);printf("Number of credits fails to match.\n");exit(8);}fclose(readfp);}int main(){int NUMBER,CREDIT,ITEMS,PRICES[2000];int i,j=0,k,position=0;char line[9000]; char* token;FILE *readfp = fopen(FILE_NAME,"r");FILE *writefp = fopen(OUT_FILE_NAME,"w");//HELLO;preread_file();NEXTLINE;position++;NUMBER = atoi(line);HELLO;for (i = 0; i<NUMBER; j = 0, i++){memset(PRICES,0,sizeof(PRICES));NEXTLINE;position++;CREDIT = atoi(line);printf("CASE %d CREDIT %d\n",i+1,CREDIT);NEXTLINE;position++;ITEMS = atoi(line);printf("CASE %d ITEMS %d\n",i+1,ITEMS);NEXTLINE;position++;token = strtok(line, " ");while (token){PRICES[j]=atoi(token);token = strtok(NULL, " ");//printf("CASE #%d,ITEMS %d\t%d\t%d\n",i+1,ITEMS,j+1,PRICES[j]);//fprintf(writefp,"CASE #%d,ITEMS=%d PRICES[%d]=%d\n",i+1,ITEMS,j+1,PRICES[j]);j++;}//fprintf(writefp,"mark:case=%d,ITEMS=%d\n",i+1,ITEMS);//MARK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!if (j!=ITEMS){printf("error here\n");printf("ITEMS fail to match the actual number at line %d.j=%d,ITEMS=%d\n",position,j,ITEMS);exit(8);}else//fprintf(writefp,"ITEMS matches the actual number at line %d.j=%d,ITEMS=%d\n",position,j,ITEMS);for (j=0;j<ITEMS-1;j++)for (k=j+1;k<ITEMS;k++)if (PRICES[j]+PRICES[k] == CREDIT){fprintf(writefp,"Case #%d: %d %d\n",i+1,j+1,k+1);//printf("Case #%d: %d %d\n",i+1,j+1,k+1);break;}}fclose(writefp);printf("out file finished.\n");return 0;}
Back to programming.
This is a Google Code Jam problem.
A good start. although I am still not sure about whether I will be a coding monkey.
- Qualification Round Africa 2010 Problem A. Store Credit
- googlecodejam.Qualification Round Africa 2010.Problem A. Store Credit
- [C++]Store Credit——Google Code Jam Qualification Round Africa 2010
- Qualification Round Africa 2010 Problem B. Reverse Words
- Store Credit-GOOGLE CODE JAM AFICA 2010 Qualification Round
- Problem A. Store Credit 第一道练习题~~
- Google code jam: Problem A. Store Credit
- (code jam)Problem A. Store Credit
- 【Google Code Jam】Problem A. Store Credit
- Qualification Round Problem A. Bot Trust-模拟
- Google Code Jam 2010 Qualification Round 资格赛 Problem A. Snapper Chain 问题A.按扣链条
- Codejam Africa and Arabia 2011 qualification round question C
- Google Code Jam 2014 Qualification Round:Problem A. Magic Trick
- Google Code Jam 2015 Qualification Round: Problem A. Standing Ovation
- 【GoogleCodeJam Qualification Round 2016】Problem A. Counting Sheep
- Google Code jam Qualification Round 2015 --- Problem A. Standing Ovation
- Code Jam 2017 Qualification Round Problem A. Oversized Pancake Flipper
- Google Code Jam 2010 Qualification Round 2012 Problem B && C
- vs2010中设置个人头文件库路径
- WP7录音-IsolatedStorage保存wav文件-IsolatedStorage上传wav录音文件(完整版)
- Spring/Hibernate/Proxool集成
- 常用正则表达式
- Chrome源码编译
- Qualification Round Africa 2010 Problem A. Store Credit
- spring依赖注入方法实例
- 松本行弘的程序世界(二)
- 判断一个数是否为素数
- spring自动装配总结
- myeclipse9.1破解方法
- 自己写的Sobel边缘检测程序
- 在WinForm/C#中打开一个文件,主要是用到进程的知识。
- .net升级到4.0之后,出现;System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798