Skip to content

Instantly share code, notes, and snippets.

@lingmujianshi
Created February 17, 2019 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lingmujianshi/f970c8dd1d0eaa0e2f14dbfed083d2f2 to your computer and use it in GitHub Desktop.
Save lingmujianshi/f970c8dd1d0eaa0e2f14dbfed083d2f2 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
cout << " 3 : " << bitset<32>(3) << endl;
cout << "~3 : " << bitset<32>(~3) << endl;
cout << "i & 3 の計算" << endl;
cout << "===========" << endl;
for(int i = 0; i < 16; i++){
cout << setw(2) << i << " & 3 = " << (i & 3) << endl;
}
cout << endl;
cout << "i & ~3 の計算" << endl;
cout << "===========" << endl;
for(int i = 0; i < 16; i++){
cout << setw(2) << i << " & ~3 = " << (i & ~3) << endl;
}
cout << endl;
cout << "4✕4マトリックス表" << endl;
cout << "===================" << endl;
for (int i = 0; i < 16; ++i){
cout << setw(2) << (i&~3)+(i%4) << " ";
if ((i+1)%4==0)
cout << endl;
}
cout << endl;
cout << "行列C=A✕B" << endl;
cout << "===================" << endl;
for (int i = 0; i < 16; ++i)
{
const int j(i & 3), k(i & ~3);
cout << "C[" << setw(2) << i << "] = ";
cout << "A[" << setw(2) << 0 + j << "] * B[" << setw(2) << k + 0 << "] + ";
cout << "A[" << setw(2) << 4 + j << "] * B[" << setw(2) << k + 1 << "] + ";
cout << "A[" << setw(2) << 8 + j << "] * B[" << setw(2) << k + 2 << "] + ";
cout << "A[" << setw(2) << 12 + j << "] * B[" << setw(2) << k + 3 << "]" << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment