Update gtk116
This commit is contained in:
parent
1a86387e6f
commit
3293661948
|
@ -1,5 +1,6 @@
|
||||||
#include "MyWin.hh"
|
#include "MyWin.hh"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
#include "image_types.hh"
|
#include "image_types.hh"
|
||||||
#include "winpe.xpm"
|
#include "winpe.xpm"
|
||||||
|
|
||||||
|
@ -9,7 +10,8 @@ hbox(Gtk::ORIENTATION_HORIZONTAL,5),
|
||||||
btnbox(Gtk::ORIENTATION_VERTICAL,5),
|
btnbox(Gtk::ORIENTATION_VERTICAL,5),
|
||||||
label_pos("(640,480)"),
|
label_pos("(640,480)"),
|
||||||
label_rgba("rgba(255,255,255,255)"),
|
label_rgba("rgba(255,255,255,255)"),
|
||||||
label_test("Color Settings And Position info")
|
label_test("Color Settings And Position info"),
|
||||||
|
label_color_str("#00000000")
|
||||||
{
|
{
|
||||||
set_icon_name("org.gtk.daleclack");
|
set_icon_name("org.gtk.daleclack");
|
||||||
background.set_size_request(640,480);
|
background.set_size_request(640,480);
|
||||||
|
@ -38,11 +40,13 @@ label_test("Color Settings And Position info")
|
||||||
|
|
||||||
//Add Color and Image Button
|
//Add Color and Image Button
|
||||||
color_btn.set_use_alpha();
|
color_btn.set_use_alpha();
|
||||||
|
color_btn.set_halign(Gtk::ALIGN_CENTER);
|
||||||
btnbox.pack_start(label_test,Gtk::PACK_SHRINK);
|
btnbox.pack_start(label_test,Gtk::PACK_SHRINK);
|
||||||
btnbox.pack_start(label_pos,Gtk::PACK_SHRINK);
|
btnbox.pack_start(label_pos,Gtk::PACK_SHRINK);
|
||||||
btnbox.pack_start(label_rgba,Gtk::PACK_SHRINK);
|
btnbox.pack_start(label_rgba,Gtk::PACK_SHRINK);
|
||||||
btnbox.pack_start(color_btn,Gtk::PACK_SHRINK);
|
btnbox.pack_start(label_color_str,Gtk::PACK_SHRINK);
|
||||||
btnbox.pack_start(btn_back,Gtk::PACK_SHRINK);
|
btnbox.pack_start(color_btn);
|
||||||
|
btnbox.pack_start(btn_back);
|
||||||
btnbox.set_valign(Gtk::ALIGN_CENTER);
|
btnbox.set_valign(Gtk::ALIGN_CENTER);
|
||||||
|
|
||||||
//Add Widgets and show all
|
//Add Widgets and show all
|
||||||
|
@ -60,6 +64,7 @@ void MyWin::get_pixel_color(int x,int y){
|
||||||
int red=0,green=0,blue=0,alpha=0;
|
int red=0,green=0,blue=0,alpha=0;
|
||||||
int n_channels = sized->get_n_channels();
|
int n_channels = sized->get_n_channels();
|
||||||
int rowstride = sized->get_rowstride(); //Rows
|
int rowstride = sized->get_rowstride(); //Rows
|
||||||
|
Glib::ustring color_str;
|
||||||
|
|
||||||
//Get Pixel data
|
//Get Pixel data
|
||||||
guint8 * pixels = sized->get_pixels();
|
guint8 * pixels = sized->get_pixels();
|
||||||
|
@ -80,16 +85,26 @@ void MyWin::get_pixel_color(int x,int y){
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set Color to rgba
|
//Set Color to rgba
|
||||||
color_set.set_red(red/25.0/255.0);
|
red/=25;blue/=25;green/=25;alpha/=25;
|
||||||
color_set.set_blue(blue/25.0/255.0);
|
color_set.set_red(red/255.0);
|
||||||
color_set.set_green(green/25.0/255.0);
|
color_set.set_blue(blue/255.0);
|
||||||
color_set.set_alpha(alpha/25.0/255.0);
|
color_set.set_green(green/255.0);
|
||||||
|
color_set.set_alpha(alpha/255.0);
|
||||||
|
|
||||||
//Get Color set as a string
|
//Get Color set as a string
|
||||||
label_rgba.set_label(color_set.to_string());
|
label_rgba.set_label(color_set.to_string());
|
||||||
|
|
||||||
//OutPut the color rgba set
|
//OutPut the color rgba set
|
||||||
color_btn.set_rgba(color_set);
|
color_btn.set_rgba(color_set);
|
||||||
|
|
||||||
|
//OutPut color Set as a Color Code
|
||||||
|
//If the image has a alpha value, use RGBA Code, else use RGB Code
|
||||||
|
if(sized->get_has_alpha()){
|
||||||
|
color_str = Glib::ustring(g_strdup_printf("#%02X%02X%02X%02X",red,blue,green,alpha));
|
||||||
|
}else{
|
||||||
|
color_str = Glib::ustring(g_strdup_printf("#%02X%02X%02X",red,blue,green));
|
||||||
|
}
|
||||||
|
label_color_str.set_label(color_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyWin::gesture_pressed(int n_press,double x,double y){
|
void MyWin::gesture_pressed(int n_press,double x,double y){
|
||||||
|
|
|
@ -11,7 +11,7 @@ class MyWin : public Gtk::Window{
|
||||||
Gtk::Button btn_back;
|
Gtk::Button btn_back;
|
||||||
Gtk::Image background;
|
Gtk::Image background;
|
||||||
Gtk::Box hbox,btnbox;
|
Gtk::Box hbox,btnbox;
|
||||||
Gtk::Label label_pos,label_rgba,label_test;
|
Gtk::Label label_pos,label_rgba,label_test,label_color_str;
|
||||||
Gtk::ColorButton color_btn;
|
Gtk::ColorButton color_btn;
|
||||||
Gtk::DrawingArea draw_area;
|
Gtk::DrawingArea draw_area;
|
||||||
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
|
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
|
||||||
|
|
|
@ -6,6 +6,34 @@ int main(int argc,char ** argv){
|
||||||
while (scanf("%d",&score)!=EOF)
|
while (scanf("%d",&score)!=EOF)
|
||||||
{
|
{
|
||||||
/* code */
|
/* code */
|
||||||
|
if(score > 100 || score < 0){
|
||||||
|
printf("Score is error!\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (score/10)
|
||||||
|
{
|
||||||
|
case 10:
|
||||||
|
case 9:
|
||||||
|
printf("A\n");
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
printf("B\n");
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
printf("C\n");
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
printf("D\n");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
case 4:
|
||||||
|
case 3:
|
||||||
|
case 2:
|
||||||
|
case 1:
|
||||||
|
case 0:
|
||||||
|
printf("E\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
//http://acm.hdu.edu.cn/showproblem.php?pid=2004
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
int main(int argc,char ** argv){
|
||||||
|
int year,month,day,sum_day=0;
|
||||||
|
while (scanf("%d/%d/%d",&year,&month,&day)!=EOF)
|
||||||
|
{
|
||||||
|
switch(month){
|
||||||
|
case 1:
|
||||||
|
sum_day+=31;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if(month%4 == 0 && month%100 != 0){
|
||||||
|
sum_day += 60;
|
||||||
|
}else{
|
||||||
|
sum_day += 59;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
case 8:
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 11:
|
||||||
|
case 12:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue