返回上一頁
juinching林俊卿(2009-06-19 01:13:34)
最後一筆測資asd...asd答案為2
#include using namespace std; int main() { string s; while(getline(cin, s)){ int c=0; int a=0; for (int i=0;i0) c++; a=0; } } if (a>0) c++; cout<
juinching林俊卿(2009-06-19 10:37:41)
#include using namespace std; int main() { long s; while(cin>>s){ int i=2; int c=0; int h=s/2; int t=0; while (1) { if (s % i==0) { t=i; c++; s/=i; } else { if (t!=0) { cout<1) cout<<"^"<h || s==1) break; c=0; t=0; } i++; } } cout<
juinching林俊卿(2009-06-19 21:33:00)
#include using namespace std; int main() { int a[9][9]; while(!cin.eof()){ int i,j; for (i=0;i<9;i++) for (j=0;j<9;j++) cin>>a[i][j]; if (a[0][0]==0) break; int s; int t=1; for (i=0;i<9;i++) { s=0; for (j=0;j<9;j++) s=s+a[i][j]; if (s!=45) t=0; } for (i=0;i<9;i++) { s=0; for (j=0;j<9;j++) s=s+a[j][i]; if (s!=45) t=0; } int k; for (k=0;k<3;k++) { s=0; for (i=0;i<3;i++) for (j=0+k*3;j<3+k*3;j++) s=s+a[i][j]; if (s!=45) t=0; s=0; for (i=3;i<6;i++) for (j=0+k*3;j<3+k*3;j++) s=s+a[i][j]; if (s!=45) t=0; s=0; for (i=6;i<9;i++) for (j=0+k*3;j<3+k*3;j++) s=s+a[i][j]; if (s!=45) t=0; } if (t==0) cout<<"no"; else cout<<"yes"; cout<
juinching林俊卿(2009-06-22 16:31:51)
#include #include using namespace std; void replace(string& modifyMe,string findMe, string newChars){ // Look in modifyMe for the "find string" // starting at position 0 int i = modifyMe.find(findMe, 0); // Did we find the string to replace? if(i != string::npos) // Replace the find string with newChars modifyMe.replace(i,newChars.size(),newChars); } int main() { map mymap; map::iterator it; mymap['M']=1000; mymap['D']=500; mymap['C']=100; mymap['L']=50; mymap['X']=10; mymap['V']=5; mymap['I']=1; char s[7]={'M','D','C','L','X','V','I'}; string x,y; int xi,yi; string ax; int d; while(cin >> x){ if (x=="#") break; cin>>y; //cout<second>=mymap.find(x[i+1])->second || i==x.length()-1) xi+=mymap.find(x[i])->second; else xi-=mymap.find(x[i])->second; } yi=0; for (i=0;isecond>=mymap.find(y[i+1])->second || i==y.length()-1) yi+=mymap.find(y[i])->second; else yi-=mymap.find(y[i])->second; } d=abs(xi-yi); //cout<=mymap.find(s[i])->second) { //cout<second; ax=ax+mymap.find(s[i])->first; } else i++; if (i>6) break; } replace(ax,"VIIII","IX "); replace(ax,"LXXXX","XC "); replace(ax,"DCCCC","CM "); replace(ax,"IIII","IV "); replace(ax,"XXXX","XL "); replace(ax,"CCCC","CD "); for (i=0;i
juinching林俊卿(2009-10-22 16:03:02)
/* gets example */ #include #include #include #include using namespace std; int main() { int i; int j; char a[1001],b[1001]; int t; gets(a); t=atoi(a); for (i=0;i