C语言文件读写
来源:互联网 发布:安卓模拟器知乎 编辑:程序博客网 时间:2024/06/08 06:15
#include <cstdio>#include<iostream>#include<string>#include<algorithm>#include<cstdlib>#include<stack>#include<queue>#include<cmath>#include<vector>#include<cstring>using namespace std; typedef struct{char name[20];}Id; /*class Exchange {public: int exchangeOddEven(int x) { int res=0; int t; stack<int> stk; while(x) { t=x%2; x/=2; stk.push(t); } int n=stk.size(); if(n%2==1){ stk.push(0); n++; } t=n; int x1;int y; //cout<<n; int k=n/2; for(int i=0;i<k;i++) { x1=stk.top(); stk.pop(); y=stk.top(); stk.pop(); //cout<<x<<" "<<y<<" "; res+=y*pow(2,--n); res+=x1*pow(2,--n); } return res; }};*/class Parenthesis {public: bool chkParenthesis(string A, int n) { char ch; int left=0; for(int i=0;i<A.length();i++) { ch=A[i]; if(ch=='(') left++; else if(ch==')') left--; if(left<0) return false; } if(left==0)return true; else return false; }};int main() { //strcpy(st.name,"wang");/*vector<int> res;for(int i=0;i<6;i++)res.push_back(i);for(int i=0;i<6;i++){cout<<res[i]<<endl;res.pop_back(); } */ /*Parenthesis A; string str="abc";if(A.chkParenthesis(str,str.length()))cout<<"yes";elsecout<<"no";*/char st[20];FILE *fp;char ch;/*fp=fopen("C:\\Users\\heisenberg\\Desktop\\test.txt","w");if(fp==0)//文件打开失败 {cout<<"NULL";exit(1);}cout<<"input a char:";ch=getchar();while(ch!='#'){fputc(ch,fp);ch=getchar();}fclose(fp);FILE *fp;*/fp=fopen("C:\\Users\\heisenberg\\Desktop\\test.txt","r");if(fp==0){cout<<"read fail";exit(1);}while((ch=fgetc(fp))!=EOF){putchar(ch);}putchar('\n');fclose(fp);return 0;//cout<<st; }
阅读全文
0 0
- c语言读写文件
- C语言读写文件
- C语言读写文件
- C语言文件读写
- C语言读写文件
- C语言文件读写
- C语言文件读写
- C语言读写文件
- C语言文件读写
- C语言读写文件
- C语言读写文件
- C语言读写文件
- C语言文件读写
- C语言读写文件
- C语言读写文件
- C语言 读写文件
- c语言读写文件
- C语言文件读写
- NKOJ-3775 数列操作
- 【学习笔记八】- JS 冒泡与捕获(事件流+事件处理程序+事件对象)
- mybatis入门dao方式写URUD(二)
- 数据结构:堆(heap)
- iOS UITableView~delegate(代理方法)
- C语言文件读写
- web网站加速之CDN技术原理
- pip安装错误:ImportError: No module named 'pkg_resources'
- Numpy 使用教程 5
- 《C++ Primer》读书笔记第九章-1- 顺序容器概述 And 容器库概览
- Java程序逻辑控制,Java循环
- 有效处理Java异常三原则
- Java CAS自旋锁
- 丁海森:大数据与排行榜,虚拟时代的营销工具