字元字串-前後字元刪除
向量
矩陣2X2
級數: 四方和
類別-三角形類別,類別輸出入,cerr追蹤。
向量
矩陣2X2
級數: 四方和
類別-三角形類別,類別輸出入,cerr追蹤。
人を呪わば穴二つ
害到自己了(傻眼
重複出現過得略過
時間分配的還是很差~只是浪費時間的判斷不變
是說整人要整得有技巧吧~直接開沒講過得東西是怎樣
cerr是啥小阿
字元字串-前後字元刪除
char* POP_FRONT(char*d){
char *s=d;
while(*d){
*d=*(d+1);
d++;
}
return s;
}
char* POP_BACK(char*d){
char *s=d;
while(*d)d++;
d--;
*d=0;
return s;
}
char *s=d;
while(*d){
*d=*(d+1);
d++;
}
return s;
}
char* POP_BACK(char*d){
char *s=d;
while(*d)d++;
d--;
*d=0;
return s;
}
向量
class Vec{
public:
double x,y,z;
Vec(double a=0,double b=0,double c=0){
x=a;//a1
y=b;//a2
z=c;//a3
}
Vec operator -(Vec&a){
return Vec(x-a.x,y-a.y,z-a.z);
}
Vec operator *(Vec&b){
return Vec(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);
}
double abs(){
return sqrt(x*x+y*y+z*z);
}
};
istream& operator>>(istream& is,Vec& vec){
cin>>vec.x>>vec.y>>vec.z;
return is;
}
向量外積~
public:
double x,y,z;
Vec(double a=0,double b=0,double c=0){
x=a;//a1
y=b;//a2
z=c;//a3
}
Vec operator -(Vec&a){
return Vec(x-a.x,y-a.y,z-a.z);
}
Vec operator *(Vec&b){
return Vec(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);
}
double abs(){
return sqrt(x*x+y*y+z*z);
}
};
istream& operator>>(istream& is,Vec& vec){
cin>>vec.x>>vec.y>>vec.z;
return is;
}
向量外積~
矩陣2X2
class Matrix{
public:
int a11,a12,a21,a22;
Matrix(int x=0,int y=0,int z=0,int w=0){
a11=x;
a12=y;
a21=z;
a22=w;
}
int det(){
return a11*a22-a12*a21;
}
Matrix operator *(Matrix &b){
return Matrix(a11*b.a11+a12*b.a21,a11*b.a12+a12*b.a22,a21*b.a11+a22*b.a21,a21*b.a12+a22*b.a22);
}
};
ostream& operator<<(ostream& os,const Matrix& m){
cout<<endl<<m.a11<<" "<<m.a12<<endl<<m.a21<<" "<<m.a22;
return os;
}
istream& operator>>(istream& is,Matrix& m){
cin>>m.a11>>m.a12>>m.a21>>m.a22;
return is;
}
矩陣真是有夠討厭
public:
int a11,a12,a21,a22;
Matrix(int x=0,int y=0,int z=0,int w=0){
a11=x;
a12=y;
a21=z;
a22=w;
}
int det(){
return a11*a22-a12*a21;
}
Matrix operator *(Matrix &b){
return Matrix(a11*b.a11+a12*b.a21,a11*b.a12+a12*b.a22,a21*b.a11+a22*b.a21,a21*b.a12+a22*b.a22);
}
};
ostream& operator<<(ostream& os,const Matrix& m){
cout<<endl<<m.a11<<" "<<m.a12<<endl<<m.a21<<" "<<m.a22;
return os;
}
istream& operator>>(istream& is,Matrix& m){
cin>>m.a11>>m.a12>>m.a21>>m.a22;
return is;
}
矩陣真是有夠討厭
級數: 四方和
#include<iostream>
using namespace std;
int f(int x){
return x*x*x*x;
}
int main(){
int n,sum=0;
cout<<"請輸入一整數n:"<<endl;
cin>>n;
for(int i=1;i<=n;i++){
sum+=f(i);
}
cout<<"答案為"<<sum;
}
using namespace std;
int f(int x){
return x*x*x*x;
}
int main(){
int n,sum=0;
cout<<"請輸入一整數n:"<<endl;
cin>>n;
for(int i=1;i<=n;i++){
sum+=f(i);
}
cout<<"答案為"<<sum;
}
類別-三角形類別,類別輸出入,cerr追蹤。
cerr是啥小朋友
扣除上面那個怪東西也不過就是class宣告個三角形罷了
不過有某些地方怪怪的~
例如show的時機很詭異、cout能不能跟cerr共用、建立Point有點錯
不曉得是不是故意的不用管輸出錯誤(CERR)也會通過
學校亂打過就好版貌似有70幾行~修訂後反倒增加到95行了(眼神死
ps.因為版面問題有兩行是特地換行的
是說我又不是在練英打!?搞屁阿
矩陣乘法弄太久了~沒辦法數學太爛
是說出題的傢伙自己確定能在時限內打完吧
扣除上面那個怪東西也不過就是class宣告個三角形罷了
不過有某些地方怪怪的~
例如show的時機很詭異、cout能不能跟cerr共用、建立Point有點錯
不曉得是不是故意的不用管輸出錯誤(CERR)也會通過
學校亂打過就好版貌似有70幾行~修訂後反倒增加到95行了(眼神死
ps.因為版面問題有兩行是特地換行的
是說我又不是在練英打!?搞屁阿
矩陣乘法弄太久了~沒辦法數學太爛
是說出題的傢伙自己確定能在時限內打完吧