真的是一件奇怪的事(部落格名希望以後可以改)
阿新 • • 發佈:2018-12-20
不認真的部落格
羞恥的想法
4
#include<cstdio> #include<iostream> #include<stack> #include<queue> #define N 20 #define HO printf("\n");system("pause"); using namespace std; int main() { int StringToNum(char * str); int isC(char *str); int isNum(char *str); queue<double> numque; stack<char> signstk; char input[N][N]; int inputlen=0; for (int i = 0; i < N; i++) { cin >> *(input+i); if (getchar() == '\n') { inputlen = i+1; break; } } for (int i = 0; i < inputlen; i++) { if (isC(*(input+i))) {signstk.push(*(*(input+i)+0));} else if (isNum(*(input+i))) {numque.push(StringToNum(*(input+i)));} } double ans=0; ans = numque.front(); while (signstk.size()) { numque.pop(); if (signstk.top() == '+') {ans += numque.front();} else if (signstk.top() == '-') {ans -= numque.front();} else if (signstk.top() == '*') {ans *= numque.front();} else if (signstk.top() == '/') {ans /= numque.front();} signstk.pop(); } printf("%.3lf", ans); HO return 0; } int StringToNum(char *str) { int len = strlen(str); int num = 0,j=0; for (int i = len - 1; i != -1 && *(str+i) != '-'; i--,j++) { num += ((*(str+i) - 48)*pow(10, j)); } if (*str == '-') return num*-1; else return num; } int isC(char *str) { if( ( (*str=='+')|| (*str == '-')|| (*str == '*')|| (*str == '/')) && (strlen(str) == 1)) return 1; else return 0; } int isNum(char *str) { if ((*(str+1) > 47 && *(str+1) < 58) || (*str > 47 && *str < 58)){if (*str == '-') return -1;else return 1;} else return 0; }
5
#include<stdio.h> #include<iostream> #define LEN 60 #define HE 3 #define DT 4 int dignum[10][9] ={{ 0,1,0,1,0,1,1,1,1 },{ 0,0,0,0,0,1,0,0,1 },{ 0,1,0,0,1,1,1,1,0 },{ 0,1,0,0,1,1,0,1,1 },{ 0,0,0,1,1,1,0,0,1 },{ 0,1,0,1,1,0,0,1,1 },{ 0,1,0,1,1,0,1,1,1 },{ 0,1,0,0,0,1,0,0,1 },{ 0,1,0,1,1,1,1,1,1 },{ 0,1,0,1,1,1,0,1,1 }}; char dig[] = {' ','_',' ','|','_','|','|','_','|'}; int dt = 0, ind = 0; char paper[HE][LEN]; char input[15]; int main() { void draw(int num); //std::cin >> input; scanf("%s",input); //emmmmmmÈç¹ûÄãÊÇVS¾Í°ÑÕâÐÐ×¢Ê͵ô°É²¢²»ÊÇscanf_sµÄÎÊÌâ for (int i = 0; input[i]!='\0'; i++) draw(input[i] - 48); for (int i = 0; i < HE; i++) { for (int j = 0; j < LEN; j++) { printf("%c",paper[i][j]); } printf("\n"); } printf("\n"); system("pause"); return 0; } void draw(int num) { for (int i = 0; i < HE; i++) { for (int j = 0+dt; j < 3 + dt; j++) { if (dignum[num][ind]) paper[i][j] = dig[ind]; else paper[i][j] = ' '; ind++; } } ind = 0; dt += DT; }
6
#include<stdio.h> #include<stdlib.h> #define SIZE 5001 #define HO printf("\n");system("pause"); int check[SIZE] = { 0 }; int primelist[SIZE] = { 0 }; int pos = 0,sum=0; int main() { void print(int *arr,int len); //void print(int *arr,int len) bool cry(int num); //{ bool piu(int num); // printf("%d ",*(arr+i)); bool eve(int num); //} bool yes(); //printf("\n"); for (int i = 2; i < SIZE; ++i) //} { if (!check[i]) primelist[pos++] = i; for (int j = 0; j < pos&&i*primelist[j] < SIZE; j++) check[i*primelist[j]] = 1; } yes(); //print(primelist,pos); HO return 0; } bool yes() { bool eve(int num); bool cry(int num); for(int i=0;i<pos;i++) if((eve(*(primelist+i)))&&cry(sum)) printf("%d ",*(primelist+i)); } bool eve(int num) { bool piu(int num);int len=0,ha=0;int sad=num; do { sum+=num%10; if(piu(num%10)) ha++; len++; num/=10; }while(num); return (ha==len)?1:0; } bool piu(int num) { return ((num == 2)||(num==3)||(num==5)||(num ==7))?1:0; } bool cry(int num) { for(int i=0;i<32;i++) if(*(primelist+i) == num) return 1; }