c++
huanle543
这个作者很懒,什么都没留下…
展开
-
c++文件读写
1.读取txt文件 fin.open("G:\\seu\\高频涂覆材料\\修改3\\s_para.txt",ios::in); //读取s参数文件 for(int i =0;i<143400;i++) { for(int k = 0;k<4;k++) fin>>s_para[i][k];原创 2015-10-29 09:49:18 · 284 阅读 · 0 评论 -
1033. 旧键盘打字(20)
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及坏掉的那些键,打出的结果文字会是怎样?输入格式:输入在2行中分别给出坏掉的那些键、以及应该输入的文字。其中对应英文字母的坏键以大写给出;每段文字是不超过105个字符的串。可用的字符包括字母[a-z, A-Z]、数字0-9、以及下划线“_”(代表空格)、“,”、“.”、“-”、“+”(代表上档键)。题目保原创 2016-03-21 19:29:03 · 335 阅读 · 0 评论 -
1032. 挖掘机技术哪家强(20)
为了用事实说明挖掘机技术到底哪家强,PAT组织了一场挖掘机技能大赛。现请你根据比赛结果统计出技术最强的那个学校。输入格式:输入在第1行给出不超过105的正整数N,即参赛人数。随后N行,每行给出一位参赛者的信息和成绩,包括其所代表的学校的编号(从1开始连续编号)、及其比赛成绩(百分制),中间以空格分隔。输出格式:在一行中给出总得分最高的学校的编号、及其总分,中间以空格分隔。题目保证答案唯一,没有并列。原创 2016-03-21 18:20:56 · 263 阅读 · 0 评论 -
1030. 完美数列(25)
给定一个正整数数列,和正整数p,设这个数列中的最大值是M,最小值是m,如果M <= m * p,则称这个数列是完美数列。现在给定参数p和一些正整数,请你从中选择尽可能多的数构成一个完美数列。输入格式:输入第一行给出两个正整数N和p,其中N(<= 105)是输入的正整数的个数,p(<= 109)是给定的参数。第二行给出N个正整数,每个数不超过109。输出格式:在一行中输出最多可以选择多少个数可以用它们原创 2016-02-24 20:38:49 · 244 阅读 · 0 评论 -
1029. 旧键盘(20)
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出肯定坏掉的那些键。输入格式:输入在2行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过80个字符的串,由字母A-Z(包括大、小写)、数字0-9、以及下划线“_”(代表空格)组成。题目保证2个字符串均非空。输出格式:按照发现顺序,在一行中输出坏掉的键。其中英文字母原创 2016-02-23 20:31:40 · 476 阅读 · 0 评论 -
1025.反转链表
#include<iostream> #include<vector> #include<cstdio> using namespace std; struct node { int add; int data; int next; }; int main() { vector<node> vin(100000);//输入原创 2015-12-15 15:57:54 · 235 阅读 · 0 评论 -
1027. 打印沙漏(20)
本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首尾符号数相等。给定任意N个符号,不一定能正好组成一个沙漏。要求打印出的沙漏能用掉尽可能多的符号。输入格式:输入在一行给出1个正整数N(<=1000)和一个符号,中间以空格分隔。输出格原创 2016-01-25 17:50:25 · 259 阅读 · 0 评论 -
1026. 程序运行时间(15)
要获得一个C语言程序的运行时间,常用的方法是调用头文件time.h,其中提供了clock()函数,可以捕捉从程序开始运行到clock()被调用时所耗费的时间。这个时间单位是clock tick,即“时钟打点”。同时还有一个常数CLK_TCK,给出了机器时钟每秒所走的时钟打点数。于是为了获得一个函数f的运行时间,我们只要在调用f之前先调用clock(),获得一个时钟打点数C1;在f执行完成后再调用cl原创 2016-01-25 17:01:37 · 274 阅读 · 0 评论 -
1024. 科学计数法
#include <iostream> #include <string> #include <sstream> using namespace std; int main() { string s; stringstream stream; int n; cin >> s; string::size_type pos = s.find('E'); string s2 = s原创 2015-12-15 15:24:45 · 252 阅读 · 0 评论 -
1022. D进制的A+B
#include <iostream> #include <vector> using namespace std; int main() { long n1, n2,n3,m,temp; vector<int> add; cin >> n1 >> n2>>m; n3 = n1 + n2; add.push_back(0); if (n3 == 0)原创 2015-12-15 14:06:18 · 215 阅读 · 0 评论 -
1021. 个位数统计
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int cnt[10] = { 0 }; for (auto c : s) { switch (c) { case '0': ++cnt[0]; br原创 2015-12-15 13:44:42 · 256 阅读 · 0 评论 -
1023. 组个最小数
题目有坑,输入的是对应数字的个数。#include <iostream> #include <vector> #include <algorithm> using namespace std; bool cmp(int i, int j) { return(i < j); }int main() { int s[10]; vector<int> real; for (int i =原创 2015-12-15 14:30:43 · 278 阅读 · 0 评论 -
1020. 月饼
#include <iostream> #include <algorithm> #include<iomanip> using namespace std; //库存可能不够,库存不一定是整数 //我自己测试库存非整数是正确,但是提交系统显示该测试点错误struct mooncake { float money; float price; double size;原创 2015-12-11 18:17:23 · 316 阅读 · 0 评论 -
1019. 数字黑洞
#include <iostream> #include <vector> #include <algorithm> using namespace std; bool big(int i, int j) { return (i > j); }bool small(int i, int j) { return (i < j); }int _tmain(int argc, _TCHAR原创 2015-12-11 15:33:29 · 284 阅读 · 0 评论 -
1017.A除以B
#include <iostream> #include <string> using namespace std; int main() { string a; int b; cin >> a >> b; int temp=0,first = 0; for (int i = 0; i < a.length();++i) { temp = temp * 10 + (a原创 2015-12-10 19:11:35 · 441 阅读 · 0 评论 -
1016.部分A+B
#include <iostream> #include <string> using namespace std; int main( ) { string a, b; int da, db; cin >> a >> da >> b >> db; int a_v = 0, b_v = 0; for (auto c:a) { if (c==da+'0') {原创 2015-12-10 18:41:40 · 195 阅读 · 0 评论 -
1018.锤子剪刀布
#include <iostream> using namespace std; int main() { int n, i; int a1 = 0, a2 = 0, a3 = 0; int aJ = 0, aC = 0, aB = 0, bJ = 0, bC = 0, bB = 0; char x, y, blank; cin >> n; for (i = 0; i < n原创 2015-12-10 20:10:20 · 245 阅读 · 0 评论 -
1031. 查验身份证(15)
一个合法的身份证号码由17位地区、日期编号和顺序编号加1位校验码组成。校验码的计算规则如下:首先对前17位数字加权求和,权重分配为:{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};然后将计算的和对11取模得到值Z;最后按照以下关系对应Z值与校验码M的值:Z:0 1 2 3 4 5 6 7 8 9 10 M:1 0 X 9 8 7 6 5 4 3 2现在给定一些身份证号码原创 2016-02-25 19:16:38 · 671 阅读 · 0 评论