UVA392 模拟(多项式输出),水
来源:互联网 发布:zbrush mac 百度云 编辑:程序博客网 时间:2024/05/16 00:54
1 题意,输入一个多项式,输出它。
2 分析。
注意模拟题思路和代码都要按部就班、步骤条理清晰,一个姿势过不了,如果觉得有更清晰的思路,就不要纠结过不了代码,而是换个姿势重新来一发。多想想题目边界、自己代码分类的边界、以及0和1等特殊情况。
3
#include <iostream>#include <stdio.h>#include <string.h>#include <math.h>#include <algorithm>using namespace std;const int maxn=10;int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int f[maxn]; memset(f,0,sizeof(f)); while(~scanf("%d",&f[8])){ ///ini for(int i=7;i>=0;i--){ scanf("%d",&f[i]); } ///print int st=0; for(int j=8;j>=0;j--){ if(f[j]!=0){ if(st==0){ st=1; if(j!=0){ ///.base_number:(底数) if(f[j]==1) cout<<""; else if(f[j]==-1) cout<<"-"; else cout<<f[j]; ///.index:(指数) if(j==1) cout<<"x"; else cout<<"x^"<<j; } else{ cout<<f[j]; } } else if(st==1){ if(j!=0){ ///.base_number: if(f[j]==1) cout<<" + "; else if(f[j]==-1) cout<<" - "; else if(f[j]>1) cout<<" + "<<f[j]; else if(f[j]<-1) cout<<" - "<<-1*f[j]; ///.index: if(j==1) cout<<"x"; else cout<<"x^"<<j; } else{ if(f[j]>0) cout<<" + "<<f[j]; else if(f[j]<0) cout<<" - "<<-1*f[j]; } } } } //cout<<endl; presentation error if(st==0) cout<<"0"<<endl; else cout<<endl; memset(f,0,sizeof(f)); }}
0 0
- UVA392 模拟(多项式输出),水
- noip2009 多项式输出 (模拟)
- 【模拟】洛谷 P1067 多项式输出
- 【洛谷】P1067 多项式输出【模拟】
- NOJ2106 6_多项式输出(模拟)
- |洛谷|NOIP2009|模拟|P1067 多项式输出
- 简单的模拟——多项式输出
- 洛谷 1067——多项式输出(简单的模拟)
- 洛谷 P1067 多项式输出(恶心纯模拟)
- 普及练习场 简单的模拟 多项式输出
- 多项式输出
- 多项式输出
- 多项式输出
- 多项式输出
- 多项式输出
- 多项式输出
- 多项式输出
- 多项式输出
- CCF-交通规划
- 浅拷贝,深拷贝,简洁版的深拷贝,浅拷贝的优化版(引用计数)
- Activity实现无动画跳转
- 使用Hexo搭建个人博客(二)
- a*自动寻路算法详解
- UVA392 模拟(多项式输出),水
- test 11-9 [水题 树链剖分 差分]
- 用最专业的态度解决最小问题
- JavaScript学习笔记1----类型、值和变量
- Docker网络操作
- HashTable
- Matlab中的color 画线的多种颜色
- 深度学习工具-caffe
- 常用的 maven 库